Skip to content

Commit bdf1a2c

Browse files
saran-twjakob
authored andcommitted
In internals.h, only look at _DEBUG when compiling with MSVC. (pybind#1855)
* In internals.h, only look at _DEBUG when compiling with MSVC. (_DEBUG is a MSVC-specific macro.)
1 parent 640b8fe commit bdf1a2c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

include/pybind11/detail/internals.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,23 +140,31 @@ struct type_info {
140140
/// Tracks the `internals` and `type_info` ABI version independent of the main library version
141141
#define PYBIND11_INTERNALS_VERSION 3
142142

143-
#if defined(_DEBUG)
143+
/// On MSVC, debug and release builds are not ABI-compatible!
144+
#if defined(_MSC_VER) && defined(_DEBUG)
144145
# define PYBIND11_BUILD_TYPE "_debug"
145146
#else
146147
# define PYBIND11_BUILD_TYPE ""
147148
#endif
148149

150+
/// On Linux/OSX, changes in __GXX_ABI_VERSION__ indicate ABI incompatibility.
151+
#if defined(__GXX_ABI_VERSION)
152+
# define PYBIND11_BUILD_ABI "_cxxabi" PYBIND11_TOSTRING(__GXX_ABI_VERSION)
153+
#else
154+
# define PYBIND11_BUILD_ABI ""
155+
#endif
156+
149157
#if defined(WITH_THREAD)
150158
# define PYBIND11_INTERNALS_KIND ""
151159
#else
152160
# define PYBIND11_INTERNALS_KIND "_without_thread"
153161
#endif
154162

155163
#define PYBIND11_INTERNALS_ID "__pybind11_internals_v" \
156-
PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) PYBIND11_INTERNALS_KIND PYBIND11_BUILD_TYPE "__"
164+
PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) PYBIND11_INTERNALS_KIND PYBIND11_BUILD_ABI PYBIND11_BUILD_TYPE "__"
157165

158166
#define PYBIND11_MODULE_LOCAL_ID "__pybind11_module_local_v" \
159-
PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) PYBIND11_INTERNALS_KIND PYBIND11_BUILD_TYPE "__"
167+
PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) PYBIND11_INTERNALS_KIND PYBIND11_BUILD_ABI PYBIND11_BUILD_TYPE "__"
160168

161169
/// Each module locally stores a pointer to the `internals` data. The data
162170
/// itself is shared among modules with the same `PYBIND11_INTERNALS_ID`.

0 commit comments

Comments
 (0)