mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-22 13:15:12 +00:00
added a comment about symbol visibility
This commit is contained in:
parent
978e376e57
commit
90d2f5e2fc
@ -1068,11 +1068,11 @@ like so:
|
||||
Partitioning code over multiple extension modules
|
||||
=================================================
|
||||
|
||||
It's straightforward to split binding code over multiple extension modules, while
|
||||
referencing types that are declared elsewhere. Everything "just" works without any special
|
||||
precautions. One exception to this rule occurs when extending a type declared
|
||||
in another extension module. Recall the basic example from Section
|
||||
:ref:`inheritance`.
|
||||
It's straightforward to split binding code over multiple extension modules,
|
||||
while referencing types that are declared elsewhere. Everything "just" works
|
||||
without any special precautions. One exception to this rule occurs when
|
||||
extending a type declared in another extension module. Recall the basic example
|
||||
from Section :ref:`inheritance`.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
@ -1113,6 +1113,26 @@ module ``basic`` has been executed.
|
||||
|
||||
Naturally, both methods will fail when there are cyclic dependencies.
|
||||
|
||||
Note that compiling code which has its default symbol visibility set to
|
||||
*hidden* (e.g. via the command line flag ``-fvisibility=hidden`` on GCC/Clang) can interfere with the
|
||||
ability to access types defined in another extension module. Workarounds
|
||||
include changing the global symbol visibility (not recommended, because it will
|
||||
lead unnecessarily large binaries) or manually exporting types that are
|
||||
accessed by multiple extension modules:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#ifdef _WIN32
|
||||
# define EXPORT_TYPE __declspec(dllexport)
|
||||
#else
|
||||
# define EXPORT_TYPE __attribute__ ((visibility("default")))
|
||||
#endif
|
||||
|
||||
class EXPORT_TYPE Dog : public Animal {
|
||||
...
|
||||
};
|
||||
|
||||
|
||||
Treating STL data structures as opaque objects
|
||||
==============================================
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user