Skip to content

gh-154643: Only use _Py_STDC_VERSION when defined - #154650

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

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

@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 90 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Oct 29, 2026
@hroncok

hroncok commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

I am unsure what more activity I shall provide. I can rebase it perhaps.

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: ‘_Py_STDC_VERSION’ is not defined, evaluates to ‘0’ [-Werror=undef]
      494 | #  elif _Py_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
for __STDC_VERSION__
but was left untouched as it is code from a bundled project
and is likely not exposed publicly.

Assisted-By: Claude Opus 4.6
@hroncok hroncok changed the title gh-154643: Only use __STDC_VERSION__ when defined gh-154643: Only use _Py_STDC_VERSION when defined Oct 29, 2026
@hroncok

hroncok commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review stale Stale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant