-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Python.h doesn't follow C99 standard. #120293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's trivial to catch.
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. |
The Python C API doesn't support |
If I try to build test_cext with that flag, the compiler fails early:
|
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). |
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. |
What I mean is that it seems impossible to build any non-trivial C extension with My example comes from Lib/test/test_cext/extension.c which is a trivial C extension which does basically nothing. |
IMO, the headers should definitely compile in pedantic mode with |
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. |
And again, to make sure it doesn't get lost in the discussion: I've started off with another error not related to
Should I open another issue for that one? |
Good idea, please open a separated issue for the cast issue in pyatomic_gcc.h. |
Done. |
I've changed the title to reflect the actual issue I was seeing (modulo the const messup). |
I fixed this issue with 9e4a81f by moving private PyCode and PyOptimizer types to the internal C API. |
It's the issue #120593 |
I tested manually and I confirm that the "ISO C99 doesn’t support unnamed structs/unions" warnings have been fixed (in code.h). I close the issue. See the remaining issue #120593 for the const qualifier. |
Thank you! |
Thanks for your report. |
Bug report
Bug description:
Hi,
I'm trying to test my C extensions with Python 3.13. For testing I usually enable as many error checks as possible. I'm seeing a couple of them. Python version is:
Some errors are related to losing const qualifiers:
Some related to C99 compatibility (not sure what the current expected compat version is):
Thanks,
CPython versions tested on:
3.13
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: