BLRuntimeInitializer Class Reference

Blend2D runtime initializer.

Calls blRuntimeInit() on entry and blRuntimeShutdown() on exit.

When using Blend2D as shared library the initialization and shutdown of the library is guaranteed by the loader, however, when Blend2D is compiled as a static library and user uses static Blend2D instances it's possible that the instance is created before Blend2D is initialized, which would be undefined behavior and would lead most likely to a crash. BLRuntimeInitializer can be used in such compilation unit to ensure that the initialization is called first. The initializer can be used more than once as Blend2D uses a counter so it would only initialize and shutdown the library once.

The default initializer of the library uses GCC/Clang extension __attribute__((init_priority(102)) if supported by the compiler. The priority is the second lowest number that is available to user code. If you are using such attribute yourself and want something initialized before Blend2D you should consider using __attribute__((init_priority(101))) while compiled by GCC/Clang.

Member Functions