]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-118124: fix assert related C++ checks on Solaris/Illumos (GH-121974) (...
authorJakub Kulík <Kulikjak@gmail.com>
Mon, 22 Jul 2024 07:45:17 +0000 (09:45 +0200)
committerGitHub <noreply@github.com>
Mon, 22 Jul 2024 07:45:17 +0000 (07:45 +0000)
Fix check for static_assert() for C++ on some platforms..
(cherry picked from commit e88bd96d0d6cf8218c4fca37e1d20399ae676a04)

Include/pymacro.h

index 342d2a7b844adfca189cc2a936bb46680029c557..d5700dc38933c49803f7db8aed4526279d5968a0 100644 (file)
 // 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