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?
I believe that the goal here is to create dynamic downloadable libraries.
, , , , - .
( 3.6.2 ISO/IEC 14882-2003) , .
, , (8.5, 9.4, 12.1, 12.6.1) . , , , .
, , X , main ( ) , , X (, X main, , ).
X
main
, , (Ada) .
Ada ( ) , , , Cish ( , , , ). "".
Ada , . "", , . , . , , , , " ".
, , , , . Ada pragma, .
pragma
. , . ( , ), Program_Error, . , PITA . , ++. , "" , .
Program_Error
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.