-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
"template with C linkage" error when including "pycore_interp.h" from C++ file #122584
Comments
It looks like This fixes the issue, but there might be other cases of this, and it's not clear how to enforce that we don't fall in this trap again. diff --git a/Include/internal/pycore_interp.h b/Include/internal/pycore_interp.h
index 45d85b2bace..f1dacc3eb3a 100644
--- a/Include/internal/pycore_interp.h
+++ b/Include/internal/pycore_interp.h
@@ -1,5 +1,8 @@
#ifndef Py_INTERNAL_INTERP_H
#define Py_INTERNAL_INTERP_H
+
+#include "pycore_mimalloc.h" // struct _mimalloc_interp_state
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -28,7 +31,6 @@ extern "C" {
#include "pycore_import.h" // struct _import_state
#include "pycore_instruments.h" // _PY_MONITORING_EVENTS
#include "pycore_list.h" // struct _Py_list_state
-#include "pycore_mimalloc.h" // struct _mimalloc_interp_state
#include "pycore_object_state.h" // struct _py_object_state
#include "pycore_optimizer.h" // _PyOptimizerObject
#include "pycore_obmalloc.h" // struct _obmalloc_state |
…22587) (cherry picked from commit 1dad23e) Co-authored-by: Michael Droettboom <[email protected]>
I can confirm that the original problem is resolved. |
I'm now curious. Why do you need to access the internal C API, pycore_interp.h? What's your use case? |
Bug report
Bug description:
Tested on official docker image
python3.13.0b4-bullseye
.pycore_interp.h
causes compiler error when included from C++ file. No problem when included from C file.mypackage/_good.c
:mypackage/_bad.cpp
(same content as above):setup.py
:Running
python setup.py build
produces error:CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: