Skip to content

Commit a273203

Browse files
committed
Make static internals ptr pybind version specific
Under gcc, the `static internals *internals_ptr` is shared across .so's, which breaks for obvious reasons. This commit fixes it by moving the static pointer declaration into a pybind-version-templated function.
1 parent 731a9f6 commit a273203

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/pybind11/cast.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ struct type_info {
4343
bool default_holder : 1;
4444
};
4545

46+
template <int = PYBIND11_VERSION_MAJOR, int = PYBIND11_VERSION_MINOR>
47+
inline internals *&get_internals_ptr() { static internals *internals_ptr = nullptr; return internals_ptr; }
48+
4649
PYBIND11_NOINLINE inline internals &get_internals() {
47-
static internals *internals_ptr = nullptr;
50+
internals *&internals_ptr = get_internals_ptr();
4851
if (internals_ptr)
4952
return *internals_ptr;
5053
handle builtins(PyEval_GetBuiltins());

0 commit comments

Comments
 (0)