10000 gh-118124: fix assert related C++ checks on Solaris/Illumos (#121974) · python/cpython@e88bd96 · GitHub
[go: up one dir, main page]

Skip to content

Commit e88bd96

Browse files
authored
gh-118124: fix assert related C++ checks on Solaris/Illumos (#121974)
Fix check for static_assert() for C++ on some platforms.
1 parent 0dcbc83 commit e88bd96

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Include/pymacro.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
// MSVC makes static_assert a keyword in C11-17, contrary to the standards.
1616
//
1717
// In C++11 and C2x, static_assert is a keyword, redefining is undefined
18-
// behaviour. So only define if building as C (if __STDC_VERSION__ is defined),
19-
// not C++, and only for C11-17.
18+
// behaviour. So only define if building as C, not C++ (if __cplusplus is
19+
// not defined), and only for C11-17.
2020
#if !defined(static_assert) && (defined(__GNUC__) || defined(__clang__)) \
21-
&& defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
22-
&& __STDC_VERSION__ <= 201710L
21+
&& !defined(__cplusplus) && defined(__STDC_VERSION__) \
22+
&& __STDC_VERSION__ >= 201112L && __STDC_VERSION__ <= 201710L
2323
# define static_assert _Static_assert
2424
#endif
2525

@@ -47,7 +47,7 @@
4747
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
4848

4949
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L \
50-
&& !defined(_MSC_VER))
50+
&& !defined(__cplusplus) && !defined(_MSC_VER))
5151
# define Py_BUILD_ASSERT_EXPR(cond) \
5252
((void)sizeof(struct { int dummy; _Static_assert(cond, #cond); }), \
5353
0)

0 commit comments

Comments
 (0)
0