From: Victor Stinner Date: Tue, 25 Jul 2023 12:27:48 +0000 (+0200) Subject: gh-105059: Use GCC/clang extension for PyObject union (#107232) X-Git-Tag: v3.13.0a1~1216 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6261585d63a31835b65d445d99dc14cca3fe9cf5;p=thirdparty%2FPython%2Fcpython.git gh-105059: Use GCC/clang extension for PyObject union (#107232) Anonymous union is new in C11. To prevent compiler warning when using -pedantic compiler option, use Clang and GCC extension on C99 and older. --- diff --git a/Include/object.h b/Include/object.h index 7182eba3adfe..2488d6cd0d40 100644 --- a/Include/object.h +++ b/Include/object.h @@ -165,6 +165,11 @@ check by comparing the reference count field to the immortality reference count. */ struct _object { _PyObject_HEAD_EXTRA +#if (defined(__GNUC__) || defined(__clang__)) \ + && !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) + // On C99 and older, anonymous union is a GCC and clang extension + __extension__ +#endif union { Py_ssize_t ob_refcnt; #if SIZEOF_VOID_P > 4