Am 09.01.2026 um 11:07 schrieb LIU Hao:
在 2026-1-9 15:48, Markus Muetzel 写道:
+#if !defined(_USE_MATH_DEFINES)
+#define _USE_MATH_DEFINES
+#endif
+
+#include <math.h>

Does it make sense to just `#define _USE_MATH_DEFINES` without the `#if`? There's such a define in xaudio2.h but I think no other code in the CRT defines that.

My thinking was that, if at some point in the future `_USE_MATH_DEFINES` was defined in `AM_CPPFLAGS` or a user manually added that flag (e.g., as a parameter to the `configure` script), that would cause a compilation error that could be avoided by guarding the definition like that.

But that point is mute in the updated patch (see below).

+float __cdecl acospif(float x)
+{
+  return acosf(x)/M_PI;
+}

Becasuse `M_PI` is a `double`, this intermediate result is calculated as

   return (float) ((double) acosf(x) / M_PI);

When looking into this, I realize that the `long double` variants are probably not correct either. Despite having 21 significant figures, `(long double)(double) M_PI` might not yield the same value as `3.14159265358979323846L`. (When suffixed with `L`, this is accurate as a `long double`.) So maybe local definitions of PI are inevitable..?


Good point.

Instead of defining the value of pi in the appropriate type repeatedly, I opted for doing that in a header that can be included in all new compilation units. (That could be simplified if _Generic macros from C11 were allowed.)

Does that look good to you?


Markus




_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to