Dynamic initialization phase of static variables

The standard states that dynamic initialization of variables of static duration (namespace scope and static class elements) should not occur before main is executed: "It is determined by the implementation regardless of whether dynamic initialization (8.5, 9.4, 12.1, 12.6.1) of the region object is performed namespaces before the first main statement. " IS 3.6.2 (3) Isn't dynamic initialization implemented [always?]? What is a better / simpler way to ensure that objects are initialized before use?

+5
source share
4 answers

I believe that the goal here is to create dynamic downloadable libraries.

, , , , - .

+4

( 3.6.2 ISO/IEC 14882-2003) , .

, , (8.5, 9.4, 12.1, 12.6.1) . , , , .

, , X , main ( ) , , X (, X main, , ).

+4

, , (Ada) .

Ada ( ) , , , Cish ( , , , ). "".

Ada , . "", , . , . , , , , " ".

, , , , . Ada pragma, .

. , . ( , ), Program_Error, . , PITA . , ++. , "" , .

+2

Dynamic initialization of variables of static duration (namespace scope and static class elements) ALWAYS occur before main starts.
The initialization order of these static duration variables is not defined.

+1
source

All Articles