This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: c++ static object not created


> 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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]