Skip to content

Commit cad5098

Browse files
skdas20claudevstinnersergey-miryanov
authored
gh-160719: Define _Py_STDC_VERSION in pyport.h (#160733)
pyport.h uses _Py_STDC_VERSION to select _Py_thread_local, _Py_NULL and _Py_TYPEOF, but the macro was defined in pymacro.h, which Python.h includes after pyport.h. The C11 and C23 branches were therefore never taken. Move the definition to pyport.h. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Sergey Miryanov <sergey.miryanov@gmail.com>
1 parent 22691a3 commit cad5098

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

‎Include/pymacro.h‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
#ifndef Py_PYMACRO_H
22
#define Py_PYMACRO_H
33

4-
// _Py_STDC_VERSION: the version of the C standard.
5-
// gh-160208: The C++ standard allows __STDC_VERSION__ to be defined to an
6-
// arbitrary value, which means we can't use __STDC_VERSION__ on C++.
7-
#if !defined(__cplusplus) && defined(__STDC_VERSION__)
8-
# define _Py_STDC_VERSION __STDC_VERSION__
9-
#endif
10-
114
// gh-91782: On FreeBSD 12, if the _POSIX_C_SOURCE and _XOPEN_SOURCE macros are
125
// defined, <sys/cdefs.h> disables C11 support and <assert.h> does not define
136
// the static_assert() macro.

‎Include/pyport.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
# error "Python's source code assumes C's unsigned char is an 8-bit type"
99
#endif
1010

11+
// _Py_STDC_VERSION: the version of the C standard.
12+
// gh-160208: The C++ standard allows __STDC_VERSION__ to be defined to an
13+
// arbitrary value, which means we can't use __STDC_VERSION__ on C++.
14+
#if defined(__STDC_VERSION__) && !defined(__cplusplus)
15+
# define _Py_STDC_VERSION __STDC_VERSION__
16+
#endif
17+
1118

1219
// Preprocessor check for a builtin preprocessor function. Always return 0
1320
// if __has_builtin() macro is not defined.

0 commit comments

Comments
 (0)