Files
cpython/Include/Python.h
Petr Viktorin ce1a877a38 gh-138143: Allow anonymous unions in public headers, using _Py_ANONYMOUS (GH-137283)
We already use an anonymous union for PyObject. This makes the workarounds available in all public headers:

- MSVC: `__pragma(warning(disable: 4201))` (with push/pop). Warning 4201 is specifically for anonymous unions, so let's disable for all of `<Python.h>`
- GCC/clang, pedantic old C standards: define `_Py_ANONYMOUS` as `__extension__`
- otherwise, define `_Py_ANONYMOUS` as nothing 

(Note that this is only for public headers -- CPython internals use C11, which has anonymous structs/unions.)

C API WG vote: https://github.com/capi-workgroup/decisions/issues/74
2025-08-26 11:14:35 +02:00

4.2 KiB