BOOST_OPENMETHOD_IMPORT_REGISTRY
Imports a registry’s state from the module that owns it.
Synopsis
BOOST_OPENMETHOD_IMPORT_REGISTRY(registry);
Used at namespace scope, after the registry’s definition, in every translation unit of every module that uses the registry without owning it. Being a declaration it may be repeated, so it belongs in the header those modules share.
Description
All of a registry’s mutable state lives in a single variable (see
registry_state). Sharing a registry across modules means sharing that one
symbol, which takes three macros: the owning module uses
BOOST_OPENMETHOD_EXPORT_REGISTRY in
the header its translation units share and
BOOST_OPENMETHOD_INSTANTIATE_REGISTRY
in exactly one of them; every client module uses
BOOST_OPENMETHOD_IMPORT_REGISTRY.
They exist to hide a platform incompatibility: on Windows, Cygwin and MinGW,
__declspec(dllexport) and extern are incompatible on an explicit
instantiation, while on ELF and Mach-O the visibility attribute must be on the
declaration and must not be repeated on the definition. See
Shared Libraries for the full discussion, including
the required link setup.
It emits an extern template declaration decorated with BOOST_SYMBOL_IMPORT
(__declspec(dllimport) on Windows, nothing on ELF). The declaration suppresses
the client’s own instantiation, so it references the owner’s symbol instead of
creating a private copy.
The client module must be linked so the reference resolves: on Windows and macOS by linking against the owning module; on ELF a dynamically loaded library may also leave it for the dynamic linker to resolve at load time.