Skip to content

Commit

Permalink
pythongh-105059: Fix MSCV compiler warning on PyObject union (pythonG…
Browse files Browse the repository at this point in the history
…H-107239)

Use pragma to ignore the MSCV compiler warning on the PyObject
nameless union.
(cherry picked from commit 1c8fe9b)

Co-authored-by: Victor Stinner <[email protected]>
  • Loading branch information
vstinner authored and miss-islington committed Jul 25, 2023
1 parent e788c0a commit 28447e3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Include/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,28 @@ 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
#ifdef _MSC_VER
// Ignore MSC warning C4201: "nonstandard extension used:
// nameless struct/union"
__pragma(warning(push))
__pragma(warning(disable: 4201))
#endif
union {
Py_ssize_t ob_refcnt;
#if SIZEOF_VOID_P > 4
PY_UINT32_T ob_refcnt_split[2];
#endif
};
#ifdef _MSC_VER
__pragma(warning(pop))
#endif

PyTypeObject *ob_type;
};

Expand Down

0 comments on commit 28447e3

Please sign in to comment.