在 2025-3-31 21:23, LIU Hao 写道:
These macros are to be used with `fesetenv()`, so they belong there.

Having these `selectany` variables in 'fenv.h' causes them to be defined with
external linkage in every source file which includes 'fenv.h'. They can also
be exported inappropriately from a DLL, which either is built with
`--export-all-symbols`, or does not contain explicit `dllexport` and is not
built with a DEF file.

Signed-off-by: LIU Hao <lh_mo...@126.com>
---
  mingw-w64-crt/misc/fesetenv.c | 16 ++++++++++++++++
  mingw-w64-headers/crt/fenv.h  |  6 +++---
  2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/mingw-w64-crt/misc/fesetenv.c b/mingw-w64-crt/misc/fesetenv.c
index 5a4426a30..432192763 100644
--- a/mingw-w64-crt/misc/fesetenv.c
+++ b/mingw-w64-crt/misc/fesetenv.c
@@ -6,6 +6,22 @@
   #include <internal.h>
  +/* The FE_DFL_ENV macro is required by standard.
+   fesetenv will use the environment set at app startup.*/
+const fenv_t __mingw_fe_dfl_env = { 0, 0 };
+
+/* The C99 standard (7.6.9) allows us to define implementation-specific macros 
for
+   different fp environments */
+#if defined(__i386__) || defined(__x86_64__)
+
+/* The default Intel x87 floating point environment (64-bit mantissa) */
+const fenv_t __mingw_fe_pc64_env = { 0x3f3f003f, 0 };
+
+/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
+const fenv_t __mingw_fe_pc53_env = { 0x3f3f103f, 0 };
+
+#endif
+
  /* 7.6.4.3
     The fesetenv function establishes the floating-point environment
     represented by the object pointed to by envp. The argument envp
diff --git a/mingw-w64-headers/crt/fenv.h b/mingw-w64-headers/crt/fenv.h
index 7d441c287..b4ab0718c 100644
--- a/mingw-w64-headers/crt/fenv.h
+++ b/mingw-w64-headers/crt/fenv.h
@@ -61,7 +61,7 @@ extern "C" {
   /* The FE_DFL_ENV macro is required by standard.
     fesetenv will use the environment set at app startup.*/
-extern const __MINGW_SELECTANY fenv_t __mingw_fe_dfl_env = { 0, 0 };
+extern const fenv_t __mingw_fe_dfl_env;
  #define FE_DFL_ENV (&__mingw_fe_dfl_env)
   /* The C99 standard (7.6.9) allows us to define implementation-specific 
macros for
@@ -69,11 +69,11 @@ extern const __MINGW_SELECTANY fenv_t __mingw_fe_dfl_env = 
{ 0, 0 };
  #if defined(__i386__) || defined(__x86_64__)
   /* The default Intel x87 floating point environment (64-bit mantissa) */
-extern const __MINGW_SELECTANY fenv_t __mingw_fe_pc64_env = { 0x3f3f003f, 0 };
+extern const fenv_t __mingw_fe_pc64_env;
  #define FE_PC64_ENV (&__mingw_fe_pc64_env)
   /* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
-extern const __MINGW_SELECTANY fenv_t __mingw_fe_pc53_env = { 0x3f3f103f, 0 };
+extern const fenv_t __mingw_fe_pc53_env;
  #define FE_PC53_ENV (&__mingw_fe_pc53_env)
   #endif



ping


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to