Skip to content

Commit 4fe34f2

Browse files
committed
gh-160208: Fix _Py_ANONYMOUS on C++
Use __extension__ on g++/clang++ to fix this g++ warning on Include/object.h: error: ISO C++ prohibits anonymous structs [-Wpedantic]
1 parent 1d53cdb commit 4fe34f2

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎Include/pymacro.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,13 @@
9595
// - MSVC has warning(disable: 4201) "nonstandard extension used : nameless
9696
// struct/union". This is specific enough that we disable it for all of
9797
// Python.h.
98-
// - GCC & clang needs __extension__ before C11
98+
// - GCC & clang needs __extension__ before C11 or on C++.
9999
// To allow unsupported platforms which need other spellings, we use a
100100
// predefined value of _Py_ANONYMOUS if it exists.
101101
#ifndef _Py_ANONYMOUS
102102
# if (defined(__GNUC__) || defined(__clang__)) \
103-
&& !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
103+
&& (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L \
104+
|| defined(__cplusplus))
104105
# define _Py_ANONYMOUS __extension__
105106
# else
106107
# define _Py_ANONYMOUS

0 commit comments

Comments
 (0)