Visual Studio - init priority dla obiektów statycznych z różnych TU

0

Jak wiadomo powszechnie, standard C++ określa kolejność inicjalizacji obiektów statycznych w ramach jednego translation unit.
3.6.2.2: [...] Other non-local variables with static storage duration have ordered initialization. Variables with ordered initialization defined within a single translation unit shall be initialized in the order of their definitions in the translation unit.
3.6.2.4: It is implementation-defined whether or not the dynamic initialization of an object of namespace scope is done before the first statement of main. If the initialization is deferred to some point in time after the first statement of main, it shall occur before the first use of any function or object defined in the same translation unit as the object to be initialized.

Natomiast kolejność inicjalizacji obiektów statycznych (konkretnie - tych o static storage duration) pomiędzy różnymi TU jest implementation defined. gcc pozwala na łatwe sterowanie tym:
init_priority (PRIORITY) In Standard C++, objects defined at namespace scope are guaranteed to be initialized in an order in strict accordance with that of their definitions in a given translation unit. No guarantee is made for initializations across translation units. However, GNU C++ allows users to control the order of initialization of objects defined at namespace scope with the init_priority attribute by specifying a relative PRIORITY, a constant integral expression currently bounded between 101 and 65535 inclusive. Lower numbers indicate a higher priority.

Czy na Visual Studio 2013 również można sterować ową kolejnością?

0

@Azarien Across translation units, however, the order of initialization is dependent on how the object files are arranged by the linker
Mam rozumieć że nie da się tym sterować?

0

Nawet jeżeli odradzam korzystania z takich sztuczek tylko na jeden kompilator.

1 użytkowników online, w tym zalogowanych: 0, gości: 1