Skip to content

Commit 9b6a1a1

Browse files
[3.15] gh-160704: Restore C11-C17 static_assert fallback (GH-160705) (GH-160825)
gh-160704: Restore C11-C17 `static_assert` fallback (GH-160705) `_Py_STDC_VERSION` needs to be defined before its value can be checked. In 8335bcb (gh-160208: Add a private wrapper around __STDC_VERSION__ (GH-160376), 2026-10-23), the condition `defined(_Py_STDC_VERSION)` is incorrectly negated, which prevents the fallback definition of `static_assert` in C11-C17 builds and causes a build error when building with an old C library that does not define `static_assert`. (cherry picked from commit a7ac7a8) Signed-off-by: Ruoyu Zhong <zhongruoyu@outlook.com> Co-authored-by: Ruoyu Zhong <zhongruoyu@outlook.com>
1 parent 3be665b commit 9b6a1a1

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

‎Include/pymacro.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// behaviour. So only define if building as C, not C++ (if __cplusplus is
2626
// not defined), and only for C11-17.
2727
#if !defined(static_assert) && (defined(__GNUC__) || defined(__clang__)) \
28-
&& !defined(_Py_STDC_VERSION) \
28+
&& defined(_Py_STDC_VERSION) \
2929
&& _Py_STDC_VERSION >= 201112L && _Py_STDC_VERSION <= 201710L
3030
# define static_assert _Static_assert
3131
#endif
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix C11-C17 builds with old C library headers that do not define
2+
``static_assert``, including glibc versions older than 2.16.

0 commit comments

Comments
 (0)