Skip to content

gh-154643: Only use __STDC_VERSION__ when defined#154650

Open
hroncok wants to merge 1 commit into
python:mainfrom
hroncok:__STDC_VERSION__
Open

gh-154643: Only use __STDC_VERSION__ when defined#154650
hroncok wants to merge 1 commit into
python:mainfrom
hroncok:__STDC_VERSION__

Conversation

@hroncok

@hroncok hroncok commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

This fixes:

$ g++ -I/usr/include/python3.15 -c -Werror=undef test.cpp
In file included from /usr/include/python3.15/Python.h:68,
                 from test.cpp:1:
/usr/include/python3.15/pyport.h:494:9: error: ‘__STDC_VERSION__’ is not defined, evaluates to ‘0’ [-Werror=undef]
  494 | #  elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
      |         ^~~~~~~~~~~~~~~~
cc1plus: some warnings being treated as errors

For any test.cpp that has #include <Python.h>.

For locating the place for the added test, I used LLM.

The main issue I could reproduce was in Include/pyport.h. Include/cpython/pyatomic.h was updated for completeness. Include/internal/mimalloc/mimalloc/atomic.h also has this but was left untouched as it is code from a bundled project and is likely not exposed publicly.

Assisted-By: Claude Opus 4.6

This fixes:

    $ g++ -I/usr/include/python3.15 -c -Werror=undef test.cpp
    In file included from /usr/include/python3.15/Python.h:68,
                     from test.cpp:1:
    /usr/include/python3.15/pyport.h:494:9: error: ‘__STDC_VERSION__’ is not defined, evaluates to ‘0’ [-Werror=undef]
      494 | #  elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
          |         ^~~~~~~~~~~~~~~~
    cc1plus: some warnings being treated as errors

For any test.cpp that has #include <Python.h>.

For locating the place for the added test, I used LLM.

The main issue I could reproduce was in Include/pyport.h.
Include/cpython/pyatomic.h was updated for completeness.
Include/internal/mimalloc/mimalloc/atomic.h also has this
but was left untouched as it is code from a bundled project
and is likely not exposed publicly.

Assisted-By: Claude Opus 4.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant