-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-45459: Add pytypedefs.h header file #31527
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
Conversation
Move forward declarations of Python C API types to a new pytypedefs.h header file to solve interdependency issues between header files. pytypedefs.h contains forward declarations of the following types: * PyCodeObject * PyFrameObject * PyGetSetDef * PyInterpreterState * PyLongObject * PyMemberDef * PyMethodDef * PyModuleDef * PyObject * PyThreadState * PyTypeObject
Last years, more and more interdependencies have been added. Examples:
This PR cleans up header files by moving forward declarations at the top of Python.h. With this PR, it becomes possible to use type names like |
If you don't want to go this way, I wrote the bare minimum fix for the clang compiler warning: GH-31539. But as I wrote in my previous comment, IMO it's now time to cleanup these forward declarations to have a sane way to fix this issuse in a single place. There are too many scattered forward declarations in the Python C API. |
Defining types in multiple header files is tricky. At my first attempt, I defined PyObject inside |
This looks nice and clean. AFAICS, there is no downside; approved post-merge :) |
Move forward declarations of Python C API types to a new pytypedefs.h header file to solve interdependency issues between header files. pytypedefs.h contains forward declarations of the following types: * PyCodeObject * PyFrameObject * PyGetSetDef * PyInterpreterState * PyLongObject * PyMemberDef * PyMethodDef * PyModuleDef * PyObject * PyThreadState * PyTypeObject
pythonGH-31527 moved this typedef to `Include/pytypedefs.h`, so this comment should point at the correct location
GH-31527 moved this typedef to `Include/pytypedefs.h`, so this comment should point at the correct location
Move forward declarations of Python C API types to a new pytypedefs.h
header file to solve interdependency issues between header files.
pytypedefs.h contains forward declarations of the following types:
https://bugs.python.org/issue45459