bpo-45459: Add pytypedefs.h header file by vstinner · Pull Request #31527 · python/cpython · GitHub
Skip to content

bpo-45459: Add pytypedefs.h header file - #31527

Merged
vstinner merged 1 commit into
python:mainfrom
vstinner:pytypedefs
Feb 24, 2022
Merged

vstinner merged 1 commit into
python:mainfrom
vstinner:pytypedefs

Conversation

@vstinner

@vstinner vstinner commented Feb 23, 2022

Copy link
Copy Markdown
Member

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

https://bugs.python.org/issue45459

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
@vstinner

Copy link
Copy Markdown
Member Author

@vstinner

vstinner commented Feb 23, 2022

Copy link
Copy Markdown
Member Author

@vstinner

Copy link
Copy Markdown
Member Author

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.

@vstinner

Copy link
Copy Markdown
Member Author

If you don't want to go this way, I wrote the bare minimum fix for the clang compiler warning: #31539.

Defining types in multiple header files is tricky. At my first attempt, I defined PyObject inside #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000 and it didn't work when building xxlimited35 which targets the limited C API version 3.5...

@erlend-aasland

Copy link
Copy Markdown
Contributor

asvetlov pushed a commit that referenced this pull request Feb 26, 2022
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
itamaro added a commit to itamaro/cpython that referenced this pull request May 24, 2022
pythonGH-31527 moved this typedef to `Include/pytypedefs.h`, so this comment should point at the correct location
vstinner pushed a commit that referenced this pull request Jul 9, 2022
GH-31527 moved this typedef to `Include/pytypedefs.h`, so this comment
should point at the correct location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants