www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/03/16/17:30:05

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "Guido S." <sassi AT uni DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: GCC 3.0.4 singleton/factory pattern
Date: Sat, 16 Mar 2002 23:25:36 +0100
Organization: Universitaet Hannover
Lines: 42
Message-ID: <a70gmq$2cv$1@newsserver.rrzn.uni-hannover.de>
References: <a70elf$1sj$1 AT newsserver DOT rrzn DOT uni-hannover DOT de>
NNTP-Posting-Host: steelrose.sedan.uni-osnabrueck.de
Mime-Version: 1.0
X-Trace: newsserver.rrzn.uni-hannover.de 1016317466 2463 131.173.58.129 (16 Mar 2002 22:24:26 GMT)
X-Complaints-To: abuse AT newsserver DOT rrzn DOT uni-hannover DOT de
NNTP-Posting-Date: 16 Mar 2002 22:24:26 GMT
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Just 4 clarification:

basically I mean, that static/globally declared Objects in different
translation units are not effecitively instantiated before main(), and
that
I interpret the standard in a way, that those are guaranteed to be
instantiated, but not in a defined order. But in 3.0.4 the are not
instantiated at all.

So I guess that this problem could be reproduced by having 2 sourcefiles
wher

File A has:

namespace {
    MyClass A;
}
-------------
and File B has
namespace {
    MyClass B;
}
---------------
and File C has

main()
{
    Do_something();    // function which needs the side effects of
                        // A's and B's construction
}

example could be that the constructor of MyClass would set a global
string
to a certain value, and Do_something() depends upon this value to be
properly setup before main() gets control. And it's not feasible to
call/instantiate A or B locally.

I don't know if it matters that MyClass is actually a template.




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019