BOOST_OPENMETHOD_INSTANTIATE_REGISTRY

Instantiates a registry’s state in the module that owns it.

Synopsis

BOOST_OPENMETHOD_INSTANTIATE_REGISTRY(registry);

Used at namespace scope, after the registry’s definition, in exactly one translation unit of the module that owns the registry. It belongs in a .cpp file, never in a header.

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 the explicit instantiation definition of the registry state, of which a program may contain only one. On declspec platforms the definition carries the dllexport; on ELF and Mach-O it carries no attribute, that having been supplied by BOOST_OPENMETHOD_EXPORT_REGISTRY in the header.