public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* CTORs for static elements
@ 2006-06-06  0:09 Perry Smith
  2006-06-06  2:52 ` Ingo Krabbe
  0 siblings, 1 reply; 2+ messages in thread
From: Perry Smith @ 2006-06-06  0:09 UTC (permalink / raw)
  To: gcc-help GCC

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?

Thanks,
Perry

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: CTORs for static elements
  2006-06-06  0:09 CTORs for static elements Perry Smith
@ 2006-06-06  2:52 ` Ingo Krabbe
  0 siblings, 0 replies; 2+ messages in thread
From: Ingo Krabbe @ 2006-06-06  2:52 UTC (permalink / raw)
  To: gcc-help; +Cc: Perry Smith

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.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-06-06  2:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-06-06  0:09 CTORs for static elements Perry Smith
2006-06-06  2:52 ` Ingo Krabbe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).