home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / cplus / 18664 < prev    next >
Encoding:
Text File  |  1993-01-04  |  1.9 KB  |  46 lines

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