home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!math.fu-berlin.de!ira.uka.de!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!news.sei.cmu.edu!fs7.ece.cmu.edu!crabapple.srv.cs.cmu.edu!POPTART.GRAPHICS.CS.CMU.EDU!baraff
- From: baraff+@cs.cmu.edu (David Baraff)
- Subject: static constructor order question
- Message-ID: <baraff.728224300@POPTART.GRAPHICS.CS.CMU.EDU>
- Sender: news@cs.cmu.edu (Usenet News System)
- Nntp-Posting-Host: poptart.graphics.cs.cmu.edu
- Organization: School of Computer Science, Carnegie Mellon
- Date: Thu, 28 Jan 1993 12:31:40 GMT
- Lines: 38
-
- I just switched to a compiler where it appears static constructors
- from libraries *aren't* called first, and I realized the
- following: (so my question is, is the following correct?)
-
- Suppose "class helper" is a class with a constructor.
- Then suppose
-
- class foo {
- static hlper important;
-
- foo() { ... code depending on 'important' having been constructed }
- ...
- };
-
- Now suppose that I have a nonlocal static foo i.e.
-
- /* file.c */
- #include <whatever.h>
-
- foo my_object;
-
- ---------
- So when my program begins, I expect 'my_object' to be constructed
- before main starts executing (or at least before 'my_object'
- is ever used). But because 'important' is not a member of 'my_object',
-
- there is no guarantee that 'important' will have been
- constructed before 'my_object' is??
-
- Is that right?
-
- -- David Baraff
- baraff@cs.cmu.edu
-
-
-
-
-
-