]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-105059: Use GCC/clang extension for PyObject union (#107232)
authorVictor Stinner <vstinner@python.org>
Tue, 25 Jul 2023 12:27:48 +0000 (14:27 +0200)
committerGitHub <noreply@github.com>
Tue, 25 Jul 2023 12:27:48 +0000 (12:27 +0000)
Anonymous union is new in C11. To prevent compiler warning
when using -pedantic compiler option, use Clang and GCC
extension on C99 and older.

Include/object.h

index 7182eba3adfe156837118db89bec7c0bb667bdc1..2488d6cd0d40e655b0015e7b57c7300351abe590 100644 (file)
@@ -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