Open sklam opened 1 month ago
It looks like mimalloc.h
is designed to be importable from either a C++ or C context, so it shouldn't be imported from inside an extern "C" { }
block.
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
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