home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Static global initialization outside of main() legal?
- Message-ID: <1993Jan4.153806.1062@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <34727@sales.GBA.NYU.EDU> <1992Dec31.191123.7222@netcom.com> <GIROD.93Jan4122311@kilohp.kiloapo.ts.tele.nokia.fi>
- Date: Mon, 4 Jan 1993 15:38:06 GMT
- Lines: 33
-
- In article <GIROD.93Jan4122311@kilohp.kiloapo.ts.tele.nokia.fi> marc.girod@ntc.nokia.com writes:
- >>>>>> On Thu, 31 Dec 1992 19:11:23 GMT, nagle@netcom.com (John Nagle) said:
- >John> You're working in a very messy area of C++. The order in which
- >John> things happen during static initialization isn't the same in different
- >John> compilers.
- >
- >Things are not so bad as John states!
-
- Oh yes they are!
-
- >The most important is
- >guaranteed: that "the initialisation [...] in a translation unit is
- >done before the first use of any function or object defined in that
- >translation unit".
-
- This is not guarranteed at all, even if it says it is!
-
- >There remains the "pathologic" case of mutual
- >dependencies, dealt with in the annotation part of the ARM for 3.4,
-
- This is not how it works. There is no general solution
- to the problem, so no algorithms can be written to solve it.
-
- Typically, what happens is static variables are initialised
- to a constant value first (0 if not otherwise specified)
- then modules get initialised in the order of linkage,
- and variables in each module in the order of writing.
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-