Static Modules    {#MicroServices_StaticModules}
==============

The normal and most flexible way to include a CppMicroServices module in an application is to compile
it into a shared library that is either linked by another library (or executable) or
\ref MicroServices_AutoLoading "auto-loaded" during runtime.

However, modules can be linked statically to your application or shared library. This makes the deployment
of your application less error-prone and in the case of a complete static build also minimizes its binary
size and start-up time. The disadvantage is that no functionality can be added without a rebuild and
redistribution of the application.

# Creating Static Modules

Static modules are written just like shared modules - there are no differences in the usage of the
CppMicroServices API or the provided preprocessor macros. The only thing you need to make sure is that
the `US_STATIC_MODULE` preprocessor macro is defined when building a module statically.

# Using Static Modules

Static modules can be used (imported) in shared or other static libraries or in the executable itself.
For every static module you would like to import, you need to put a call to `#US_IMPORT_MODULE` or
to `#US_INITIALIZE_STATIC_MODULE` (if the module does not provide an activator) into the
source code of the importing library.

\note While you can link static modules to other static modules, you will still need to
import *all* of the static modules into the final executable to ensure proper initialization.

Example code for importing the static module `MyStaticModule1` into another library
or executable:

\snippet uServices-staticmodules/main.cpp ImportStaticModuleIntoMain

# A Note About Import Ordering    {#MicroServices_StaticModules_Order}

Although static linking reduces the number of shared libraries, the statically
linked modules are still represented internally by distinct Module and ModuleContext
objects. In a shared module scenario, the linker dependencies define the load order
of modules and hence the order of their initialization and ModuleActivator::Load()
invocations. In the static case, the order of the `#US_IMPORT_MODULE` macro calls
defines the initialization and activation order. It is therefore important to
always import static modules in the correct dependency order.
