Sujet : Pre-main construction order in modules De : Muttley (at) *nospam* DastardlyHQ.org Groupes :comp.lang.c++ Date : 30. Mar 2025, 09:57:54 Autres entêtes Organisation : A noiseless patient Spider Message-ID :<vsb12i$2mv42$1@dont-email.me>
I was curious about the order in which objects get constructed in modules before main gets called. It seems with both Clang and gcc its the order in which the modules were linked together to form the runnable binary so if the link order was m1.o m2.o then anything in m1 would get constructed first. Vice verca if you switch the order.
Is this codified in the standard or is it left up to compiler and linker writers to decide how they order this?