BOOST_OPENMETHOD_IMPORT_REGISTRY

Import a registry's state from the module that owns it.

Synopsis

Declared in <boost/openmethod/macros.hpp>

#define BOOST_OPENMETHOD_IMPORT_REGISTRY(REGISTRY)

Description

All of a registry's mutable state lives in a single variable (see boost::openmethod::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.

Use 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. Everything it emits is fully qualified, so there is no need to be inside, or to open, namespace boost::openmethod.

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.

Parameters

Name

Description

REGISTRY

The registry to import. May be any registry, predefined or user‐defined.

See Also

Shared Libraries for the full discussion, including the required link setup.

Created with MrDocs