C++ Constructors on global vars not being run ?
C++ Constructors on global vars not being run ?
- Subject: C++ Constructors on global vars not being run ?
- From: Peter Mulholland <email@hidden>
- Date: Mon, 24 Sep 2007 06:06:53 +0100
Hello xcode-users,
To simplify the problem a bit, suppose I have:
class something
{
public:
something()
{
printf("In constructor for something()\n");
somevar = 123;
}
int somevar;
} atest;
int main(int argc, char *argv[])
{
printf("atest.somevar is %d\n", atest.somevar);
return 0;
}
When I compile code similar to this on gcc, and run it, the
constructor isn't being called before main(), even though it should
be.
What's going on? I looked at settings for ld but couldn't find
anything that handled ctors.
--
Best regards,
Peter mailto:email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden