gh-105059: Fix MSCV compiler warning on PyObject union (#107239) · python/cpython@1c8fe9b

GitHub

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 */

166166struct_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

173180union {

174181Py_ssize_tob_refcnt;

175182#ifSIZEOF_VOID_P>4

176183PY_UINT32_Tob_refcnt_split[2];

177184#endif

178185 };

186+#ifdef_MSC_VER

187+__pragma(warning(pop))

188+#endif

189+179190PyTypeObject*ob_type;

180191};

181192