-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
bpo-38353: Cleanup includes in the internal C API #16548
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
Use forward declaration of types to avoid includes in the internal C API. Add also comment to justify other includes.
@brettcannon: Thanks for the review ;-) |
|
#include "pycore_pystate.h" | ||
#include "pythread.h" | ||
/* Forward declarations */ | ||
typedef struct pyruntimestate _PyRuntimeState; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact that 3 different headers need this same typedef makes me wonder if it might be worth having a short header called pycore_state_typedefs.h
that was enough to allow declaration of APIs accepting state pointers, without needing to include the full state struct definitions.
Something like:
typedef struct _PyArgv _PyArgv;
typedef struct pyruntimestate _PyRuntimeState;
typedef struct _is PyInterpreterState;
struct _ceval_runtime_state;
Adding a new header file requires to modify the Unix (Makefile.pre.in) and the Windows (Visual Studio project files, at least 2 files) build systems. IMHO it's too annoying. I'm fine with duplicating these forward definitions. |
Hmm, I thought it was only new C files that were that annoying to add, but I admit it's been ages since I added a new header file. |
Use forward declaration of types to avoid includes in the internal C API. Add also comment to justify other includes.
Use forward declaration of types to avoid includes in the internal C
API. Add also comment to justify other includes.
https://bugs.python.org/issue38353