python / python/cpython

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

未關閉
#154,643 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

build type-bug
主要語言
Python
星號
77.2k
分支
35.9k
PR 合併指標
PR 指標待擷取

描述

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

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

從 Include/pyport.h 第 494 行附近和提交 2cefa70eb92321c39f7d66bd862b2f66cd06f0fa 開始。使用帶有 -Werror=undef 的 g++ 重現 CPython 3.15 的標頭建置,並檢查連結的 PR gh-154650 以了解目前方向。在指定的警告設定下,回報的 Python.h 引入不再失敗,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
cpp, python
領域
build-system
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。