diff --git a/Include/pymacro.h b/Include/pymacro.h index 41dfd9155b9b24..9e2d7bc21c0bed 100644 --- a/Include/pymacro.h +++ b/Include/pymacro.h @@ -95,12 +95,13 @@ // - MSVC has warning(disable: 4201) "nonstandard extension used : nameless // struct/union". This is specific enough that we disable it for all of // Python.h. -// - GCC & clang needs __extension__ before C11 +// - GCC & clang needs __extension__ before C11 or on C++. // To allow unsupported platforms which need other spellings, we use a // predefined value of _Py_ANONYMOUS if it exists. #ifndef _Py_ANONYMOUS # if (defined(__GNUC__) || defined(__clang__)) \ - && !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) + && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L \ + || defined(__cplusplus)) # define _Py_ANONYMOUS __extension__ # else # define _Py_ANONYMOUS