Repository navigation
object.h:131:16: error: ISO C++ prohibits anonymous structs [-Wpedantic] #160208
Copy link
Copy link
Closed
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
The test_cext test fails on Python 3.14.9 and 3.15.1 with the following error:
building '_test_cppext' extension
creating build/temp.solaris-2.11-i86pc.64bit-cpython-315
/usr/gcc/14/bin/g++ -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -m64 -O3 -g -gdwarf-4 -gstrict-dwarf -msave-args -fno-reorder-functions -fno-reorder-blocks-and-partition -D_XOPEN_SOURCE=600 -D__EXTENSIONS__=1 -D_XPG6 -D_REENTRANT -fPIC -I/data/builds/oi-py315/components/python/python-315/build/amd64/build/test_python_154508æ/tempcwd/env/include -I/data/builds/oi-py315/components/python/python-315/Python-3.15.1/Include -I/data/builds/oi-py315/components/python/python-315/build/amd64 -c extension.cpp -o build/temp.solaris-2.11-i86pc.64bit-cpython-315/extension.o -Wall -Wextra -Werror -DMODULE_NAME=_test_cppext -pedantic-errors -Wno-long-long
In file included from /data/builds/oi-py315/components/python/python-315/Python-3.15.1/Include/Python.h:79,
from extension.c:16,
from extension.cpp:3:
/data/builds/oi-py315/components/python/python-315/Python-3.15.1/Include/object.h:131:16: error: ISO C++ prohibits anonymous structs [-Wpedantic]
131 | struct {
| ^
error: command '/usr/gcc/14/bin/g++' failed with exit code 1
error: subprocess-exited-with-error
× Building wheel for internal__test_cppext (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> No available output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: '/data/builds/oi-py315/components/python/python-315/build/amd64/build/test_python_154508æ/tempcwd/env/bin/python' '/data/builds/oi-py315/components/python/python-315/build/amd64/build/test_python_154508æ/tempcwd/env/lib/python3.15/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py' build_wheel /tmp/test_python_9fsz780f/tmp1lo16wpw
cwd: /data/builds/oi-py315/components/python/python-315/build/amd64/build/test_python_154508æ/tempcwd/pkg
Building wheel for internal__test_cppext (pyproject.toml): finished with status 'error'
ERROR: Failed building wheel for internal__test_cppext
Failed to build internal__test_cppext
error: failed-wheel-build-for-install
Linked PRs
- gh-160208: Mark PyObject inner struct as anonymous #160214
- gh-160208: Fix typo in test_cext tests name #160216
- [3.15] gh-160208: Fix typo in test_cext tests name (GH-160216) #160223
- [3.14] gh-160208: Fix typo in test_cext tests name (GH-160216) #160224
- gh-160208: Fix _Py_ANONYMOUS on C++ #160332
- gh-160208: Add a private wrapper around __STDC_VERSION__ #160376
- [3.15] gh-160208: Add a private wrapper around __STDC_VERSION__ (GH-160376) #160437
- [3.14] gh-160208: Fix PyObject structure on C++ #160562
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Activity
[-]object.h:125:16: error: ISO C++ prohibits anonymous structs [-Wpedantic][/-][+]object.h:131:16: error: ISO C++ prohibits anonymous structs [-Wpedantic][/+]pythongh-160208: Mark PyObject inner struct as anonymous
vstinner commentedon Oct 22, 2026
Hi. What is your g++ version and operating system name and version? Can you attach the full test_cext output as a file?
Can you try attached #160214 to see if it does fix the g++ warning for you?
I cannot reproduce the issue on Fedora 44 with g++ 16.2.1.
mtelka commentedon Oct 22, 2026
OS and version: OpenIndiana Hipster
Full test log: test_cext.log
vstinner commentedon Oct 22, 2026
Ok, so two C++ tests using
-pedantic-errorsoption fail:TestInternalCpp doesn't fail since it doesn't use
-pedantic-errors(oops, there is a typo in the code, it's writtenTestInteralCpp).gh-160208: Fix typo in test_cext tests name (#160216)
[3.14] gh-160208: Fix typo in test_cext tests name (GH-160216) (#160224)
[3.15] gh-160208: Fix typo in test_cext tests name (GH-160216) (#160223)
mtelka commentedon Oct 22, 2026
With ef524c6:
vstinner commentedon Oct 22, 2026
I can reproduce the issue on OpenIndiana and g++ 14.3.0 with this C++ program:
Example:
I can also reproduce the g++ compiler error on Fedora 44 with g++ 16.2.1.
What's special about OpenIndiana is that C headers like
<stdint.h>do define__STDC_VERSION__macro:Output on OpenIndiana (macro defined):
Output on Fedora 44 (macro NOT defined):
gh-160208: Add a private wrapper around __STDC_VERSION__ (GH-160376)
[3.15] gh-160208: Add a private wrapper around __STDC_VERSION__ (GH-1…
mtelka commentedon Oct 23, 2026
@encukou Please note that 3.14 does have the same issue. I'd really appreciate it if 3.14 is fixed too. Thank you.
encukou commentedon Oct 23, 2026
Please skip the test (or patch this) in your builds. Per PEP 11, we generally don't backport fixes for unsupported platforms to maintenance branches.
The test failure is harmless (except for building extensions with C++ &
-pedantic-errors, which I wouldn't recommend). The test is more of a warning for us about out-of-spec features sneaking into the headers.mtelka commentedon Oct 23, 2026
@encukou okay. Understood. Thank you!
vstinner commentedon Oct 24, 2026
I created #160562 to fix PyObject on Python 3.14.