Thanks for the fast response! I have now included the updated patch

Best Regards,
Luca

________________________________
Da: LIU Hao
Inviato: Lunedì, 07 Luglio, 2025 15:40
A: mingw-w64-public@lists.sourceforge.net; Luca Bacci
Oggetto: Re: [Mingw-w64-public] Provide definition of math_errhandling

在 2025-7-7 20:52, Luca Bacci 写道:
> Question: should I really define the macros conditionally on __STDC_VERSION__?
>

I suspect not.

But the value of `math_errhandling` should be subject to GCC command-line 
options, like this:

    #if defined __FAST_MATH__   /* no error handling.  */
    # define math_errhandling  0
    #elif defined __NO_MATH_ERRNO__  /* errno is not used; only exceptions.  */
    # define math_errhandling  MATH_ERREXCEPT
    #else
    # define math_errhandling  (MATH_ERRNO | MATH_ERREXCEPT)
    #endif


It's awkward that these macros are documented in different manuals. Anyway, 
thank goodness, they are.


[1] https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-ffast-math
[2] https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html




--
Best regards,
LIU Hao
From b88d9a84147aae6bec734bed25409625b5a8cd3d Mon Sep 17 00:00:00 2001
From: Luca Bacci <luca.ba...@outlook.com>
Date: Mon, 7 Jul 2025 14:46:09 +0200
Subject: [PATCH] math.h: Provide definition of math_errhandling

https://en.cppreference.com/w/c/numeric/math/math_errhandling.html

Signed-off-by: Luca Bacci <luca.ba...@outlook.com>
---
 mingw-w64-headers/crt/math.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/mingw-w64-headers/crt/math.h b/mingw-w64-headers/crt/math.h
index 65c41cd..4ee3b73 100644
--- a/mingw-w64-headers/crt/math.h
+++ b/mingw-w64-headers/crt/math.h
@@ -168,6 +168,14 @@ extern "C" {
   #define __setusermatherr __mingw_setusermatherr
 #endif
 
+#if defined __FAST_MATH__  /* no error handling.  */
+# define math_errhandling  0
+#elif defined __NO_MATH_ERRNO__  /* errno is not used; only exceptions.  */
+# define math_errhandling  MATH_ERREXCEPT
+#else
+# define math_errhandling  (MATH_ERRNO | MATH_ERREXCEPT)
+#endif
+
   double __cdecl sin(double _X);
   double __cdecl cos(double _X);
   double __cdecl tan(double _X);
-- 
2.49.0.windows.1

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

Reply via email to