python / python/cpython

/usr/include/python3.15/pyport.h:494:9: error: ‘__STDC_VERSION__’ is not defined, evaluates to ‘0’ [-Werror=undef]

Open
#154,643 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

Hello. When building the kmymoney Fedora package, we got:

In file included from /usr/include/python3.15/Python.h:68,
                 from /builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/plugins/woob/interface/woobinterface.cpp:16:
/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__)
      |         ^~~~~~~~~~~~~~~~

The package uses g++, not gcc.

It has:

#include <Python.h>

The compiler invocation is:

cd /builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/misc && /usr/bin/g++ -DKF_DEPRECATED_WARNINGS_SINCE=0x60000 -DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x56200C -DQT_CORE_LIB -DQT_DEPRECATED_WARNINGS_SINCE=0x60000 -DQT_DISABLE_DEPRECATED_BEFORE=0x50f02 -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_CAST_TO_ASCII -DQT_NO_DEBUG -DQT_NO_FOREACH -DQT_NO_KEYWORDS -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_NO_URL_CAST_FROM_STRING -DQT_STRICT_ITERATORS -DQT_USE_QSTRINGBUILDER -D_GNU_SOURCE -D_LARGEFILE64_SOURCE -Dkmm_gpgfile_EXPORTS -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/misc -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/misc -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/misc/kmm_gpgfile_autogen/include -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2 -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/settings -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/settings -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/dialogs -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/widgets -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/widgets -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/mymoney -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/mymoney/storage -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/interfaces -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/interfaces -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/plugins -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/plugins -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/views -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/dialogs -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/converter -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/dialogs/settings -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/mymoney/storage -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/mymoney -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/wizards/endingbalancedlg -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/wizards/endingbalancedlg -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/wizards/newinvestmentwizard -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/wizards/newinvestmentwizard -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/wizards/newloanwizard -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/wizards/newloanwizard -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/wizards/wizardpages -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/models -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/models -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/icons -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/icons -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/kmymoney/menus -I/builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/menus -isystem /usr/include/qt6/QtCore -isystem /usr/include/qt6 -isystem /usr/lib64/qt6/mkspecs/linux-g++ -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -Wall -Wextra -Wcast-align -Wchar-subscripts -Wformat-security -Wno-long-long -Wpointer-arith -Wundef -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type -Werror=init-self -Werror=undef -Wvla -Wdate-time -Wsuggest-override -Wlogical-op -pedantic -Wzero-as-null-pointer-constant -Wmissing-include-dirs -fexceptions -DNDEBUG -std=c++17 -fPIC -fvisibility=hidden -fvisibility-inlines-hidden   -UQT_NO_CAST_FROM_ASCII -UQT_NO_CAST_FROM_BYTEARRAY -UQT_NO_CAST_TO_ASCII -UQT_NO_CAST_TO_BYTEARRAY -Wall -Wextra -Wlogical-op -Wno-null-dereference -Wshadow -Wunused -Wno-misleading-indentation -Wsuggest-override -Wcast-qual -Wformat=2 -fno-common -Werror=return-type -Wzero-as-null-pointer-constant -MD -MT kmymoney/misc/CMakeFiles/kmm_gpgfile.dir/kmm_gpgfile_autogen/mocs_compilation.cpp.o -MF CMakeFiles/kmm_gpgfile.dir/kmm_gpgfile_autogen/mocs_compilation.cpp.o.d -o CMakeFiles/kmm_gpgfile.dir/kmm_gpgfile_autogen/mocs_compilation.cpp.o -c /builddir/build/BUILD/kmymoney-5.2.2-build/kmymoney-5.2.2/redhat-linux-build/kmymoney/misc/kmm_gpgfile_autogen/mocs_compilation.cpp

I think that 2cefa70eb92321c39f7d66bd862b2f66cd06f0fa might have exposed the # elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) line outside of # ifdef Py_BUILD_CORE causign this issue.

I don't know yet if there is some other thing that makes other g++ code work and not this one, perhaps it's just the -Werror=undef part. Other code in CPython uses defined(__STDC_VERSION__) && __STDC_VERSION__ .... Perhaps this needs the same treatment?

Fedora bug report: https://bugzilla.redhat.com/show_bug.cgi?id=2440571 (fixed by disabling the woob plugin).

CPython versions tested on:

3.15

Operating systems tested on:

Linux

Linked PRs
  • gh-154650

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Include/pyport.h around line 494 and commit 2cefa70eb92321c39f7d66bd862b2f66cd06f0fa. Reproduce the CPython 3.15 header build using g++ with -Werror=undef and inspect linked PR gh-154650 for the current direction. Done means the reported Python.h inclusion no longer fails under the stated warning configuration.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, python
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.