You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You cannot create an embedded module whose name is an existing C++ namespace or other symbol. I think this should not be a strange situation: creating a Python module that wraps a C++ library and takes its namespace as name.
This fails if physics is already a C++ namespace:
PYBIND11_EMBEDDED_MODULE(physics, m)
The PYBIND11_EMBEDDED_MODULE(name, variable) macro prefixes name many times when defining its needed symbols to avoid clashes, except once, when defining the actual pybind11::detail::embedded_module object. I doubt this object's name is relevant in the C++ side, what is relevant is the real module name, seen by Python.
Proposed solution
I would prefix that object just like the others. Line 64 in "embed.h":
This avoids a potential conflict with names in the same scope of the
same name as the embedded module, like namespaces or other global
variables.
Fixespybind#2172
This avoids a potential conflict with names in the same scope of the
same name as the embedded module, like namespaces or other global
variables.
Fixes#2172
Issue description
You cannot create an embedded module whose name is an existing C++ namespace or other symbol. I think this should not be a strange situation: creating a Python module that wraps a C++ library and takes its namespace as name.
This fails if
physics
is already a C++ namespace:PYBIND11_EMBEDDED_MODULE(physics, m)
The
PYBIND11_EMBEDDED_MODULE(name, variable)
macro prefixesname
many times when defining its needed symbols to avoid clashes, except once, when defining the actualpybind11::detail::embedded_module
object. I doubt this object's name is relevant in the C++ side, what is relevant is the real module name, seen by Python.Proposed solution
I would prefix that object just like the others. Line 64 in "embed.h":
pybind11::detail::embedded_module name(PYBIND11_TOSTRING(name)
Could be changed to:
pybind11::detail::embedded_module PYBIND11_CONCAT(pybind11_module_, name)(PYBIND11_TOSTRING(name)
In the above example the global object created would be
pybind11_module_physics
which does not collide.The text was updated successfully, but these errors were encountered: