added a comment about symbol visibility

This commit is contained in:
Wenzel Jakob 2016-04-11 14:30:11 +02:00
parent 978e376e57
commit 90d2f5e2fc
1 changed files with 25 additions and 5 deletions

View File

@ -1068,11 +1068,11 @@ like so:
Partitioning code over multiple extension modules Partitioning code over multiple extension modules
================================================= =================================================
It's straightforward to split binding code over multiple extension modules, while It's straightforward to split binding code over multiple extension modules,
referencing types that are declared elsewhere. Everything "just" works without any special while referencing types that are declared elsewhere. Everything "just" works
precautions. One exception to this rule occurs when extending a type declared without any special precautions. One exception to this rule occurs when
in another extension module. Recall the basic example from Section extending a type declared in another extension module. Recall the basic example
:ref:`inheritance`. from Section :ref:`inheritance`.
.. code-block:: cpp .. code-block:: cpp
@ -1113,6 +1113,26 @@ module ``basic`` has been executed.
Naturally, both methods will fail when there are cyclic dependencies. 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 Treating STL data structures as opaque objects
============================================== ==============================================