c++ static object not created
Kövesdi György
kgy@deverto.hu
Wed Nov 19 15:31:00 GMT 2008
> static SomeClass my_instance;
>
> I found that if there is no reference to this instance, then gcc does not
> call its constructor at all.
> How can it be forced?
I found that if there is another similar object in this file which is
referenced externally, then the constructor of my_instance is also called,
even if it is marked static, and has no references.
I have gcc 4.3.1 on SuSE 11.0
uname -a
Linux notebook 2.6.25.18-0.2-pae #1 SMP 2008-10-21 16:30:26 +0200 i686 i686
i386 GNU/Linux
Thanx
K. Gy.
More information about the Gcc-help
mailing list