From 53a004c0dd2180d575f4d0acd6fcb49f7f9912b9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 23 Oct 2026 18:36:13 -0700 Subject: [PATCH] gh-160208: Fix PyObject structure on C++ Use __extension__ on the anonymous union. --- Include/object.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Include/object.h b/Include/object.h index a67a4cdb3c138b..e6fd16c3670a36 100644 --- a/Include/object.h +++ b/Include/object.h @@ -109,7 +109,8 @@ whose size is determined when the object is allocated. #ifndef Py_GIL_DISABLED struct _object { #if (defined(__GNUC__) || defined(__clang__)) \ - && !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L) + && (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L \ + || defined(__cplusplus)) // On C99 and older, anonymous union is a GCC and clang extension __extension__ #endif