Skip to content

Commit 627d528

Browse files
vstinnermiss-islington
authored andcommitted
pythongh-105059: Use GCC/clang extension for PyObject union (pythonGH-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 <vstinner@python.org>
1 parent fab36fb commit 627d528

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Include/object.h

Lines changed: 5 additions & 0 deletions
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)