4 ms·
Don't try this with C++, unless you're certain that there are no interdependencies or side-effects in global variable initialisation. The link order (usually) a
by matzf 4y ago
Don't try this with C++, unless you're certain that there are no interdependencies or side-effects in global variable initialisation. The link order (usually) affects the order in which initialisers are executed.
- Asooka 4y agoOn the contrary: do do this and if you observe your program crashing due to linking order, fix the damn bug.
- londons_explore 4y agoDoes the C++ spec guarantee initialization order? Or is any application that depends on it relying on undefined behaviour?
- theg5prank 4y agoThere's no mandated order between compilation units. It's a problem significant enough to have its own snarky name: the Static Initialization Order Fiasco https://en.cppreference.com/w/cpp/language/siof https://en.cppreference.com/w/cpp/language/siof