From fdc1629266a8decd7597e9b9670fc5eb9d21c5b9 Mon Sep 17 00:00:00 2001 From: LIU Hao Date: Sat, 2 Nov 2024 16:35:23 +0800 Subject: [PATCH] fwd: Update `__MCF_MAY_THROW` to use `__MCF_CXX()` (cherry picked from commit 140ef0e32c510f00448a643c72cedf825b0b2e52) Signed-off-by: LIU Hao --- mcfgthread/fwd.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mcfgthread/fwd.h b/mcfgthread/fwd.h index 61f2e25676..0a556cee9a 100644 --- a/mcfgthread/fwd.h +++ b/mcfgthread/fwd.h @@ -56,8 +56,13 @@ # define __MCF_UNREACHABLE __assume(0) #endif -#if defined _MSC_VER && defined __cplusplus -# define __MCF_MAY_THROW throw(...) +/* Generally speaking, functions are either `__MCF_MAY_THROW` or `noexcept`. This + * macro is necessary for Visual Studio (but not CL.EXE from command-line), which + * defaults to `/EHsc`, which assumes that `extern "C"` functions can't throw C++ + * exceptions. Not only is this behavior not conforming to the C++ standard, it + * can also result in wrong code about `__MCF_gthr_call_once_seh()`. */ +#if defined _MSC_VER +# define __MCF_MAY_THROW __MCF_CXX(throw(...)) #else # define __MCF_MAY_THROW #endif