This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: c++ static object not created
- From: KÃvesdi GyÃrgy <kgy at deverto dot hu>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 19 Nov 2008 15:51:58 +0100
- Subject: Re: c++ static object not created
- References: <200811191522.56224.kgy@deverto.hu>
> 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.