summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub KulĂ­k <Kulikjak@gmail.com>2024-07-21 16:50:14 (GMT)
committerGitHub <noreply@github.com>2024-07-21 16:50:14 (GMT)
commite88bd96d0d6cf8218c4fca37e1d20399ae676a04 (patch)
tree4f5cf33a97d8827019fe3eaae97d2b567b63afe8
parent0dcbc8385322ff51f7fc3e586027d880275df4fa (diff)
downloadcpython-e88bd96d0d6cf8218c4fca37e1d20399ae676a04.zip
cpython-e88bd96d0d6cf8218c4fca37e1d20399ae676a04.tar.gz
cpython-e88bd96d0d6cf8218c4fca37e1d20399ae676a04.tar.bz2
gh-118124: fix assert related C++ checks on Solaris/Illumos (#121974)
Fix check for static_assert() for C++ on some platforms.
-rw-r--r--Include/pymacro.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/Include/pymacro.h b/Include/pymacro.h
index a7945ef..e0378f9 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
@@ -47,7 +47,7 @@
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
- && !defined(_MSC_VER))
+ && !defined(__cplusplus) && !defined(_MSC_VER))
# define Py_BUILD_ASSERT_EXPR(cond) \
((void)sizeof(struct { int dummy; _Static_assert(cond, #cond); }), \
0)