gnucap-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnucap-devel] Feedback needed, especially non-Linux


From: al davis
Subject: Re: [Gnucap-devel] Feedback needed, especially non-Linux
Date: Thu, 22 Feb 2007 19:57:37 -0500
User-agent: KMail/1.9.5

On Thursday 22 February 2007 19:15, David Fang wrote:
> > Consider this program....
> > ================
> > #include <iostream>
> > class foo {
> > public:
> >   foo() {std::cout << "Hello world\n";}
> > } x;
> >
> > int main() {}
> > ================
>
> Solution:
>
> If you need iostream facilities during global initialization
> (pre-main), you can guarantee it is set up by inserting:
>
> static const std::ios_base::Init _init;
>
> before uses of std::cout, etc...
>
> > Does it work?
> > How?

Are you telling me that it doesn't?  Ahh. ... link order 
problem.  The language spec requires this to work.  It works 
for me.

Is that Init_init documented anywhere, in the C++ standard 
document?  I did not see it in Stroustrup's book.  If not, it 
is not portable either, no improvement over the link order 
issue.  If I have 100 files like this, should I put that in all 
100 of them?  It looks like a hack..

> By the same token, it also makes sure the stream facilities
> stay alive long enough during global destruction, (some
> reference-count like mechanism) since destruction happens in
> reverse order (within each translation unit).

Destruction happens in reverse order, period.  That is, in 
reverse of the actual construction order.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]