-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Move #include
directives before extern "C" {
in internal headers
#115105
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
Yes, it sounds like a good idea. It took me a while, but I think that I understood the C++20 module issue: #110845 (comment) |
If someone asks, let's make them happy, but I don't think we need to do this proactively. |
I suggest to close this issue in this case. |
@albanD asked me about this a week or two ago in the context of PyTorch. I'm not sure if it's still an issue or if it's been worked around. |
@albanD, please speak if this is an issue for you. |
In TorchDynamo eval_frame.c was implemented in C (as opposed to C++ like the rest of PyTorch), because CPython headers (internal/pycore_frame.h, internal/pycore_pystate.h, etc) did not work from C++. This was a few years ago at this point, so I forget the exact error -- but the workaround was to implement that one file in C. We would prefer for that file to be implemented in C++. |
Thanks for considering our request.
As you might imagine, this is fairly brittle (very dependent on cpython core include changes) and prevents us from using c++ as with the rest of our codebase. |
For _PyWeakref_ClearRef, see capi-workgroup/decisions#25 |
Is there anything that should be exposed as public (potentially unstable) API, that we could document, test and support? If you want the compiled code to match CPython, you will want to compile it as C. Especially if you've already taught your build system to do that. I don't think the From a quick look at the code, it seems that you're reaching into the kind internals that change as CPython is optimized. I'm afraid I don't have advice for you other than: think about what could be contributed to CPython, and what could be put behind a supported API boundary. I will close this issue. If you must use internal headers, then I think compiling them as C is the way to go. Discussion about bigger issues than moving |
Feature or enhancement
Some of our internal headers (e.g.,
pycore_ceval.h
) contain#include
directives inside theextern "C" {
blocks. This can cause problems if system headers are included within anextern "C" {
block and the header is compiled as C++ code. For a similar issue with the public headers, see #110845.As far as I can tell, nobody has complained about this yet, but I think we might as well address this sooner rather later.
cc @ericsnowcurrently @gpshead @vstinner
The text was updated successfully, but these errors were encountered: