Description
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 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":
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.