Comments (14)
Previously: #105059
git blame fingers 060a96f / #117144
from cpython.
It's trivial to catch.
$ cat /tmp/foo.c
#include <Python.h>
$ gcc -std=c99 -Werror=pedantic -I/usr/include/python3.13 -c /tmp/foo.c -o /tmp/foo.o
In file included from /usr/include/python3.13/Python.h:92,
from /tmp/foo.c:1:
/usr/include/python3.13/cpython/code.h:32:10: error: ISO C99 doesn’t support unnamed structs/unions [-Werror=pedantic]
32 | };
| ^
/usr/include/python3.13/cpython/code.h:34:6: error: ISO C99 doesn’t support unnamed structs/unions [-Werror=pedantic]
34 | };
| ^
/usr/include/python3.13/cpython/code.h:27:9: error: struct has no named members [-Werror=pedantic]
27 | typedef struct {
| ^~~~~~
In file included from /usr/include/python3.13/Python.h:128:
/usr/include/python3.13/cpython/optimizer.h:60:14: error: ISO C99 doesn’t support unnamed structs/unions [-Werror=pedantic]
60 | };
| ^
/usr/include/python3.13/cpython/optimizer.h:62:10: error: ISO C99 doesn’t support unnamed structs/unions [-Werror=pedantic]
62 | };
| ^
/usr/include/python3.13/cpython/optimizer.h:63:6: error: ISO C99 doesn’t support unnamed structs/unions [-Werror=pedantic]
63 | };
| ^
cc1: some warnings being treated as errors
If the objective is to continue supporting external users of Python.h that unlike cpython, haven't upgraded to c11 -- then this seems like a useful unittest to add.
from cpython.
from cpython.
The Python C API doesn't support -Werror=pedantic
compiler flag. I don't think that it's a flag that we want to support. I suggest closing the issue as "WONT FIX".
from cpython.
If I try to build test_cext with that flag, the compiler fails early:
building 'cext' extension
gcc -fno-strict-overflow -Wsign-compare -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -Og -Wall -fPIC -I/home/vstinner/python/main/env/include -I/home/vstinner/python/main/Include -I/home/vstinner/python/main -c extension.c -o build/temp.linux-x86_64-cpython-314-pydebug/extension.o -Werror -Werror=pedantic -Werror=declaration-after-statement -DMODULE_NAME=cext
extension.c:56:19: error: ISO C forbids conversion of function pointer to object pointer type [-Werror=pedantic]
56 | {Py_mod_exec, (void*)_testcext_exec},
| ^
from cpython.
Hmm. -pedantic support is not documented in PEP 7. Any pointers for a documentation here?
That being said - the change of title is not right. It was one -pedantic error (with C99 - it does work with C11, thatswhy the question about version compat). However, the first error is related to -Wcast-qual (and definitely seems valid to me).
from cpython.
If I try to build test_cext with that flag, the compiler fails early:
building 'cext' extension gcc -fno-strict-overflow -Wsign-compare -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -Og -Wall -fPIC -I/home/vstinner/python/main/env/include -I/home/vstinner/python/main/Include -I/home/vstinner/python/main -c extension.c -o build/temp.linux-x86_64-cpython-314-pydebug/extension.o -Werror -Werror=pedantic -Werror=declaration-after-statement -DMODULE_NAME=cext extension.c:56:19: error: ISO C forbids conversion of function pointer to object pointer type [-Werror=pedantic] 56 | {Py_mod_exec, (void*)_testcext_exec}, | ^
I'd like to add that it's not about compiling my extension, I can deal with that. It's simply about including Python.h.
from cpython.
I'd like to add that it's not about compiling my extension, I can deal with that.
What I mean is that it seems impossible to build any non-trivial C extension with -Werror=pedantic
, since Python requires syntax which is denied by -Werror=pedantic
. Like my example.
My example comes from Lib/test/test_cext/extension.c which is a trivial C extension which does basically nothing.
from cpython.
IMO, the headers should definitely compile in pedantic mode with -std=c11
, since that checks we actually use the standard we chose.
Possibly with C99 too. IMO, having an anonymous union in the public headers is a regression in 3.13.
from cpython.
FWIW, I'm casting the member functions like this and gcc doesn't complain:
#define EXT_CFUNC(func) ((PyCFunction)(void (*) (void))(func))
[...]
PyDoc_STRVAR(myfunc__doc__,
"myfunc(self)...");
[...]
static PyObject *
myfunc(mytype_t *self)
{
...
return someobject;
}
[...]
static PyMethodDef mytype_methods[] = {
[...]
{"somename", EXT_CFUNC(myfunc), METH_NOARGS, myfunc__doc__},
[...]
I looked into the headers, to verify what I'm doing here and I might have just stolen that from _PyCFunction_CAST (methodobject.h) a long time ago. I don't remember.
from cpython.
And again, to make sure it doesn't get lost in the discussion: I've started off with another error not related to -pedantic
:
/usr/include/python3.13/cpython/pyatomic_gcc.h: In function '_Py_atomic_load_ptr': /usr/include/python3.13/cpython/pyatomic_gcc.h:300:34: error: cast discards 'const' qualifier from pointer target type [-Werror=cast-qual] 300 | { return (void *)__atomic_load_n((void **)obj, __ATOMIC_SEQ_CST); } | ^ /usr/include/python3.13/cpython/pyatomic_gcc.h: In function '_Py_atomic_load_ptr_relaxed': /usr/include/python3.13/cpython/pyatomic_gcc.h:359:34: error: cast discards 'const' qualifier from pointer target xt (line 8))
Should I open another issue for that one?
from cpython.
Good idea, please open a separated issue for the cast issue in pyatomic_gcc.h.
from cpython.
Good idea, please open a separated issue for the cast issue in pyatomic_gcc.h.
Done.
from cpython.
I've changed the title to reflect the actual issue I was seeing (modulo the const messup).
from cpython.
Related Issues (20)
- 3.12.4 breaks`logging.config.DictConfig` with `logging.handlers.QueueHandler` on read-only file systems
- Add tests for new Tk widget options
- [RFE] `fields` and `time_*` properties must not be used on UUIDs that are time-agnostic. HOT 6
- [C API] Add PyObject_VectorcallDict() to the limited C API HOT 1
- shutil's move function fails to handle files opened by another process
- Texto HOT 4
- Intel vPro® Platform TEI Study by Forrester
- Bump the bundled pip version to 24.1.x
- Git for Administrators - MoodleDocs HOT 2
- V20.14.0 HOT 1
- Typo in `urllib.parse` docs: Incorrect parameter name
- Generator store recall HOT 2
- Incoming.md
- Freethreading interpreter will attempt to import unsupported stable ABI extension modules HOT 4
- `FrameLocalsProxy` is stricter than `dict` about what constitutes a match HOT 13
- lgtm/
- ValueError in importlib.metadata for eggs with files installed outside the site packages
- Given type X = T ... X does not dereference to T HOT 2
- Simplify consumers by adding `*.Queue.iter()` and `*.Queue.iter_nowait()` HOT 2
- queue.SimpleQueue() uses just a list in it's C implementation. deque wouuld be much faster. HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.