This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: CTORs for static elements
- From: Ingo Krabbe <ikrabbe dot ask at web dot de>
- To: gcc-help at gcc dot gnu dot org
- Cc: Perry Smith <pedz at easesoftware dot com>
- Date: Tue, 6 Jun 2006 04:52:47 +0200
- Subject: Re: CTORs for static elements
- References: <210ACC8B-01FD-44E8-B3FD-ADDCD56DBAC6@easesoftware.com>
Am Dienstag, 6. Juni 2006 02:09 schrieb Perry Smith:
> I have a class like:
>
> class f {
> public:
> f() : l(-1) { }
>
> private:
> int l;
> };
>
> I then have a global static instance of f. Is GCC going to create a
> CTOR function and call it when the program starts up or is it going
> to just put f::l into an initialized data area? My other question
> (not gcc specific) is if this is specified in the C++ language?
I would say C++ defines that the CTOR is created at compilation time but
called when the program starts and that's how gcc should behave.