Re: Pre-main construction order in modules

Liste des GroupesRevenir à cl c++ 
Sujet : Re: Pre-main construction order in modules
De : Muttley (at) *nospam* DastardlyHQ.org
Groupes : comp.lang.c++
Date : 30. Mar 2025, 17:09:38
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vsbqc2$1rk0n$1@dont-email.me>
References : 1 2 3 4
On Sun, 30 Mar 2025 15:59:05 GMT
Mr Flibble <flibble@reddwarf.jmc.corp> wibbled:
On Sun, 30 Mar 2025 15:30:34 +0000, Muttley wrote:
>
On Sun, 30 Mar 2025 10:38:57 -0400 James Kuyper
<jameskuyper@alumni.caltech.edu> wibbled:
On 3/30/25 4:57 AM, Muttley@DastardlyHQ.org wrote:
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?
>
Section 6.9.3.3 does in fact impose many constraints on the sequence in
which non-local objects with static storage duration get initialized.
However, all of the sequence requirements are only between objects
defined in the same translation unit. Also, it's implementation-defined
which of those initializations occur before the start of main().
 
Initialising global objects before main is an absolute must otherwise
how are you expected to use them safely? They're not in the code for
decoration.
>
Global variables are really bad, you are wrong to think it is OK to use
them.

You're entitled to your opinion. I tend to use a few global objects, often
singletons that contain most of the code. Having them global means I don't
have to pass a reference into every damn function in one object that requires
the other object.


Date Sujet#  Auteur
30 Mar 25 * Pre-main construction order in modules67Muttley
30 Mar 25 +* Re: Pre-main construction order in modules2Richard Damon
30 Mar 25 i`- Re: Pre-main construction order in modules1Bonita Montero
30 Mar 25 `* Re: Pre-main construction order in modules64James Kuyper
30 Mar 25  `* Re: Pre-main construction order in modules63Muttley
30 Mar 25   +* Re: Pre-main construction order in modules30Muttley
30 Mar 25   i+* Re: Pre-main construction order in modules14Muttley
30 Mar 25   ii+- Re: Pre-main construction order in modules1Richard Damon
31 Mar 25   ii+- Re: Pre-main construction order in modules1Muttley
31 Mar 25   ii`* Re: Pre-main construction order in modules11Bonita Montero
31 Mar 25   ii +* Re: Pre-main construction order in modules9Paavo Helde
31 Mar 25   ii i`* Re: Pre-main construction order in modules8Bonita Montero
31 Mar 25   ii i +- Re: Pre-main construction order in modules1Richard Damon
31 Mar 25   ii i `* Re: Pre-main construction order in modules6Paavo Helde
31 Mar 25   ii i  `* Re: Pre-main construction order in modules5Bonita Montero
31 Mar 25   ii i   +- Re: Pre-main construction order in modules1Paavo Helde
1 Apr 25   ii i   `* Re: Pre-main construction order in modules3Jakob Bohm
1 Apr 25   ii i    +- Re: Pre-main construction order in modules1Bonita Montero
1 Apr 25   ii i    `- Re: Pre-main construction order in modules1Paavo Helde
31 Mar 25   ii `- Re: Pre-main construction order in modules1Richard Damon
30 Mar 25   i`* Re: Pre-main construction order in modules15Bonita Montero
30 Mar 25   i `* Re: Pre-main construction order in modules14Bonita Montero
30 Mar 25   i  `* Re: Pre-main construction order in modules13Bonita Montero
30 Mar 25   i   `* Re: Pre-main construction order in modules12Bonita Montero
30 Mar 25   i    +- Re: Pre-main construction order in modules1Richard Damon
30 Mar 25   i    `* Re: Pre-main construction order in modules10Bonita Montero
30 Mar 25   i     `* Re: Pre-main construction order in modules9Chris M. Thomasson
31 Mar 25   i      `* Re: Pre-main construction order in modules8Bonita Montero
1 Apr 25   i       `* Re: Pre-main construction order in modules7Chris M. Thomasson
1 Apr 25   i        `* Re: Pre-main construction order in modules6Bonita Montero
1 Apr 25   i         `* Re: Pre-main construction order in modules5Chris M. Thomasson
1 Apr 25   i          `* Re: Pre-main construction order in modules4Bonita Montero
1 Apr 25   i           `* Re: Pre-main construction order in modules3Fred. Zwarts
1 Apr 25   i            `* Re: Pre-main construction order in modules2Bonita Montero
1 Apr 25   i             `- Re: Pre-main construction order in modules1Bonita Montero
31 Mar 25   +* Re: Pre-main construction order in modules25Paavo Helde
31 Mar 25   i+* Re: Pre-main construction order in modules23Muttley
31 Mar 25   ii`* Re: Pre-main construction order in modules22Paavo Helde
31 Mar 25   ii `* Re: Pre-main construction order in modules21Muttley
31 Mar 25   ii  +- Re: Pre-main construction order in modules1Paavo Helde
1 Apr 25   ii  `* Re: Pre-main construction order in modules19James Kuyper
1 Apr 25   ii   `* Re: Pre-main construction order in modules18Muttley
1 Apr 25   ii    +* Re: Pre-main construction order in modules11Paavo Helde
1 Apr 25   ii    i+* Re: Pre-main construction order in modules6Muttley
1 Apr 25   ii    ii`* Re: Pre-main construction order in modules5Paavo Helde
1 Apr 25   ii    ii +- Re: Pre-main construction order in modules1Muttley
1 Apr 25   ii    ii `* Re: Pre-main construction order in modules3Michael S
1 Apr 25   ii    ii  +- Re: Pre-main construction order in modules1Muttley
1 Apr 25   ii    ii  `- Re: Pre-main construction order in modules1Muttley
1 Apr 25   ii    i`* Re: Pre-main construction order in modules4Michael S
1 Apr 25   ii    i +* Re: Pre-main construction order in modules2Paavo Helde
1 Apr 25   ii    i i`- Re: Pre-main construction order in modules1Muttley
1 Apr 25   ii    i `- Re: Pre-main construction order in modules1James Kuyper
1 Apr 25   ii    `* Re: Pre-main construction order in modules6James Kuyper
1 Apr 25   ii     +- Re: Pre-main construction order in modules1Chris M. Thomasson
1 Apr 25   ii     +* Re: Pre-main construction order in modules2Michael S
2 Apr 25   ii     i`- Re: Pre-main construction order in modules1James Kuyper
2 Apr 25   ii     +- Re: Pre-main construction order in modules1James Kuyper
2 Apr 25   ii     `- Re: Pre-main construction order in modules1Muttley
31 Mar 25   i`- Re: Pre-main construction order in modules1Bonita Montero
31 Mar 25   `* Re: Pre-main construction order in modules7James Kuyper
1 Apr 25    `* Re: Pre-main construction order in modules6Jakob Bohm
1 Apr 25     `* Re: Pre-main construction order in modules5James Kuyper
1 Apr 25      `* Re: Pre-main construction order in modules4Michael S
1 Apr 25       +- Re: Pre-main construction order in modules1Keith Thompson
1 Apr 25       +- Re: Pre-main construction order in modules1James Kuyper
2 Apr 25       `- Re: Pre-main construction order in modules1David Brown

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal