Closed
Description
Bug report
Bug description:
When compiling a program that links against the Python libraries (and uses their headerfiles) with the -Werror=declaration-after-statement
compiler flag enabled, the following error occurs:
/usr/include/python3.12/object.h:233:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
233 | PyVarObject *var_ob = _PyVarObject_CAST(ob);
This is fairly similar to previous issue #92781.
Although the C90 style may be archaic and perhaps not worth supporting at some point, maintaining support could be helpful for some downstream platforms (I encountered this in Debian bug #1057442).
Minimal test cases to show that the problem did not occur with Python 3.11.8 and that it does occur on Python 3.12.2 and to help verify any fixes.
#include "/usr/include/python3.11/Python.h"
#include "/usr/include/python3.11/object.h"
int main() {}
#include "/usr/include/python3.12/Python.h"
#include "/usr/include/python3.12/object.h"
int main() {}
Compiled in either case using:
$ gcc bugreport.c -Werror=declaration-after-statement
or equivalently, using llvm
v17:
$ clang-17 bugreport.c -Werror=declaration-after-statement
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Linked PRs
- gh-116869: Make C API compatible with ISO C90 #116950
- gh-116869: Add test_cext test: build a C extension #116954
- gh-116869: Fix redefinition of the _PyOptimizerObject type #116963
- gh-116869: Enable test_cext and test_cppext on Free Threading build #116973
- gh-116869: Build test_cext with -Werror=declaration-after-statement #116990
- gh-116869: Test the limited C API in test_cext #116995
- gh-116869: Fix test_cext on RHEL7 #117010
- [3.12] gh-116869: Make C API compatible with ISO C90 (GH-116950) #117011
- gh-116869: Fix test_cext for Free Threading #117043
- gh-116869: Enable -Werror in test_cext for Free Threading #117106