Skip to content

Commit 6261585

Browse files
authored
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.
1 parent 2425346 commit 6261585

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)