https://github.com/python/cpython/commit/82db81528c0e66d88d252e6a0eb4d9b1e686535a
commit: 82db81528c0e66d88d252e6a0eb4d9b1e686535a
branch: 3.13
author: Jakub KulĂ­k <[email protected]>
committer: vstinner <[email protected]>
date: 2024-07-22T07:50:20Z
summary:

[3.13] gh-118124: fix assert related C++ checks on Solaris/Illumos (GH-121974) 
(#122108)

Fix check for static_assert() for C++ on some platforms..
(cherry picked from commit e88bd96d0d6cf8218c4fca37e1d20399ae676a04)

files:
M Include/pymacro.h

diff --git a/Include/pymacro.h b/Include/pymacro.h
index b388c2a4a663ce..e3e9cd13594814 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -15,11 +15,11 @@
 // MSVC makes static_assert a keyword in C11-17, contrary to the standards.
 //
 // In C++11 and C2x, static_assert is a keyword, redefining is undefined
-// behaviour. So only define if building as C (if __STDC_VERSION__ is defined),
-// not C++, and only for C11-17.
+// behaviour. So only define if building as C, not C++ (if __cplusplus is
+// not defined), and only for C11-17.
 #if !defined(static_assert) && (defined(__GNUC__) || defined(__clang__)) \
-     && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
-     && __STDC_VERSION__ <= 201710L
+     && !defined(__cplusplus) && defined(__STDC_VERSION__) \
+     && __STDC_VERSION__ >= 201112L && __STDC_VERSION__ <= 201710L
 #  define static_assert _Static_assert
 #endif
 
@@ -46,7 +46,8 @@
 /* Argument must be a char or an int in [-128, 127] or [0, 255]. */
 #define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
 
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
+     && !defined(__cplusplus))
 #  define Py_BUILD_ASSERT_EXPR(cond) \
     ((void)sizeof(struct { int dummy; _Static_assert(cond, #cond); }), \
      0)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to