Re: Use static variable across multiple files??
* jamm:
Alf P. Steinbach wrote:
the C++ "static initialization
fiasco" e.g. in the FAQ (a very popular GUI framework suffers from this,
constraining its use severely).
Just wondering, which GUI framework are you referring to?
wxWidgets for Windows. It's not a problem with "normal" use but I tried to use
it as underlying implementation of some more general functionality. The code is
peppered with macros that generate rather unsafe static initializations (it blew
up for my use, I started fixing things, but finally gave up, it was too much).
Hm, interesting. I wasn't sure about which GUI library so I had to search among
old projects. And when I finally found that one it had another interesting file:
<code>
struct Foo {};
struct Naughty {};
struct X: Naughty, Foo
{
#ifdef CX
X(): Naughty(), Foo() {}
#else
X() {}
#endif
};
int main()
{
X* p = new X;
delete p; // !!! defined(CX) blows up with MSVC 7.1 debug build.
}
</code>
Cheers,
- Alf