summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-07-25 15:35:49 (GMT)
committerGitHub <noreply@github.com>2023-07-25 15:35:49 (GMT)
commit9c31d9405027cea9c2d039ade672d604663ed5b0 (patch)
tree2d4f1fc53a68c79cb8221c3b96ec68af56d4b5bc /Include
parente788c0aeeb46bdfa3c4d8a39fb9bbb505e6d27a8 (diff)
downloadcpython-9c31d9405027cea9c2d039ade672d604663ed5b0.zip
cpython-9c31d9405027cea9c2d039ade672d604663ed5b0.tar.gz
cpython-9c31d9405027cea9c2d039ade672d604663ed5b0.tar.bz2
[3.12] gh-105059: Fix MSCV compiler warning on PyObject union (GH-107239) (#107248)
gh-105059: Fix MSCV compiler warning on PyObject union (GH-107239) Use pragma to ignore the MSCV compiler warning on the PyObject nameless union. (cherry picked from commit 1c8fe9bdb624d356643ee569151a9e4f2963179a) Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Include')
-rw-r--r--Include/object.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/Include/object.h b/Include/object.h
index 542f8d8..77434e3 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -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;
};