--
Best regards,
LIU Hao

From 0ab21a6aef1a82e87ee31d88b1f8d5feba88a6d7 Mon Sep 17 00:00:00 2001
From: LIU Hao <[email protected]>
Date: Mon, 11 Nov 2024 23:59:26 +0800
Subject: [PATCH 1/2] headers/_mingw: Add macros for conditional `constexpr`

Signed-off-by: LIU Hao <[email protected]>
---
 mingw-w64-headers/crt/_mingw.h.in | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/mingw-w64-headers/crt/_mingw.h.in 
b/mingw-w64-headers/crt/_mingw.h.in
index 5a36facd3..bc6a3afd3 100644
--- a/mingw-w64-headers/crt/_mingw.h.in
+++ b/mingw-w64-headers/crt/_mingw.h.in
@@ -97,6 +97,20 @@ limitations in handling dllimport attribute.  */
 #endif
 #endif
 
+/* Recent MSVC supports C++14 but it doesn't define __cplusplus accordingly.  
*/
+#define __MINGW_CXX11_CONSTEXPR
+#define __MINGW_CXX14_CONSTEXPR
+#ifdef __cplusplus
+# if __cplusplus >= 201103L || defined(_MSC_VER)
+#  undef __MINGW_CXX11_CONSTEXPR
+#  define __MINGW_CXX11_CONSTEXPR  constexpr
+# endif
+# if __cplusplus >= 201402L || defined(_MSC_VER)
+#  undef __MINGW_CXX14_CONSTEXPR
+#  define __MINGW_CXX14_CONSTEXPR  constexpr
+# endif
+#endif
+
 #ifdef __cplusplus
 # define __UNUSED_PARAM(x)
 #else
-- 
2.47.0

From 6e20f43a4fad9715095e06b844d525aac3b3826a Mon Sep 17 00:00:00 2001
From: LIU Hao <[email protected]>
Date: Tue, 12 Nov 2024 00:00:50 +0800
Subject: [PATCH 2/2] headers/winnt: Make enum flag operators `constexpr` for
 C++11

Signed-off-by: LIU Hao <[email protected]>
---
 mingw-w64-headers/include/winnt.h | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/mingw-w64-headers/include/winnt.h 
b/mingw-w64-headers/include/winnt.h
index df87eb1f7..007539a66 100644
--- a/mingw-w64-headers/include/winnt.h
+++ b/mingw-w64-headers/include/winnt.h
@@ -706,13 +706,13 @@ typedef LONG RTL_REFERENCE_COUNT32, 
*PRTL_REFERENCE_COUNT32;
 #ifdef __cplusplus
 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) \
 extern "C++" { \
-inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) 
| ((int)b)); } \
-inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE 
&)(((int &)a) |= ((int)b)); } \
-inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) 
& ((int)b)); } \
-inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE 
&)(((int &)a) &= ((int)b)); } \
-inline ENUMTYPE operator ~ (ENUMTYPE a) { return ENUMTYPE(~((int)a)); } \
-inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { return ENUMTYPE(((int)a) 
^ ((int)b)); } \
-inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) { return (ENUMTYPE 
&)(((int &)a) ^= ((int)b)); } \
+__MINGW_CXX11_CONSTEXPR inline ENUMTYPE operator | (ENUMTYPE a, ENUMTYPE b) { 
return ENUMTYPE(((int)a) | ((int)b)); } \
+__MINGW_CXX11_CONSTEXPR inline ENUMTYPE &operator |= (ENUMTYPE &a, ENUMTYPE b) 
{ return (ENUMTYPE &)(((int &)a) |= ((int)b)); } \
+__MINGW_CXX11_CONSTEXPR inline ENUMTYPE operator & (ENUMTYPE a, ENUMTYPE b) { 
return ENUMTYPE(((int)a) & ((int)b)); } \
+__MINGW_CXX11_CONSTEXPR inline ENUMTYPE &operator &= (ENUMTYPE &a, ENUMTYPE b) 
{ return (ENUMTYPE &)(((int &)a) &= ((int)b)); } \
+__MINGW_CXX11_CONSTEXPR inline ENUMTYPE operator ~ (ENUMTYPE a) { return 
ENUMTYPE(~((int)a)); } \
+__MINGW_CXX11_CONSTEXPR inline ENUMTYPE operator ^ (ENUMTYPE a, ENUMTYPE b) { 
return ENUMTYPE(((int)a) ^ ((int)b)); } \
+__MINGW_CXX11_CONSTEXPR inline ENUMTYPE &operator ^= (ENUMTYPE &a, ENUMTYPE b) 
{ return (ENUMTYPE &)(((int &)a) ^= ((int)b)); } \
 }
 #else
 #define DEFINE_ENUM_FLAG_OPERATORS(ENUMTYPE) /* */
-- 
2.47.0

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

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

Reply via email to