Skip to content

Commit 1c8fe9b

Browse files
authored
gh-105059: Fix MSCV compiler warning on PyObject union (#107239)
Use pragma to ignore the MSCV compiler warning on the PyObject nameless union.
1 parent 1a3faba commit 1c8fe9b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Include/object.h

+11
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,28 @@ check by comparing the reference count field to the immortality reference count.
165165
*/
166166
struct _object {
167167
_PyObject_HEAD_EXTRA
168+
168169
#if (defined(__GNUC__) || defined(__clang__)) \
169170
&& !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)
170171
// On C99 and older, anonymous union is a GCC and clang extension
171172
__extension__
173+
#endif
174+
#ifdef _MSC_VER
175+
// Ignore MSC warning C4201: "nonstandard extension used:
176+
// nameless struct/union"
177+
__pragma(warning(push))
178+
__pragma(warning(disable: 4201))
172179
#endif
173180
union {
174181
Py_ssize_t ob_refcnt;
175182
#if SIZEOF_VOID_P > 4
176183
PY_UINT32_T ob_refcnt_split[2];
177184
#endif
178185
};
186+
#ifdef _MSC_VER
187+
__pragma(warning(pop))
188+
#endif
189+
179190
PyTypeObject *ob_type;
180191
};
181192

0 commit comments

Comments
 (0)