Skip to content

Commit

Permalink
pythongh-105059: Use GCC/clang extension for PyObject union (python#1…
Browse files Browse the repository at this point in the history
…07232)

Anonymous union is new in C11. To prevent compiler warning
when using -pedantic compiler option, use Clang and GCC
extension on C99 and older.
  • Loading branch information
vstinner authored Jul 25, 2023
1 parent 2425346 commit 6261585
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6261585

Please sign in to comment.