This is the mail archive of the
mailing list for the GCC project.
Global static variables
- To: gcc mailinglist <gcc at gcc dot gnu dot org>
- Subject: Global static variables
- From: Soeren Grimm <soeren at viatronix dot net>
- Date: Fri, 18 May 2001 10:54:29 -0400
i don't know where i exactly should ask this. By i think may be this is
We have a huge project with different modules. So we wanna make our own
Like std::out, but with special features. But for this we must somehow
ensure that there is only ONE instance of the outputstream in the whole
static outputsteam dbg;
extern outputstream dbg,
Then we include global. h in all files.
Problem of solution 1: multiple instance of dbg;
Problem of solution 2: we can't ensure that the instance is constructed
The outputstream itself could be used in constructors of other classes.
What is the right way to define something really global and only once?
Thanks in advance