Skip to content

Commit 0cf5f6a

Browse files
[3.12] gh-105059: Use GCC/clang extension for PyObject union (GH-107232) (#107236)
gh-105059: Use GCC/clang extension for PyObject union (GH-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. (cherry picked from commit 6261585) Co-authored-by: Victor Stinner <[email protected]>
1 parent fab36fb commit 0cf5f6a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Include/object.h

+5
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ check by comparing the reference count field to the immortality reference count.
165165
*/
166166
struct _object {
167167
_PyObject_HEAD_EXTRA
168+
#if (defined(__GNUC__) || defined(__clang__)) \
169+
&& !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)
170+
// On C99 and older, anonymous union is a GCC and clang extension
171+
__extension__
172+
#endif
168173
union {
169174
Py_ssize_t ob_refcnt;
170175
#if SIZEOF_VOID_P > 4

0 commit comments

Comments
 (0)