Re: c++ static object not created

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

 



> 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.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux