Re: C++ Constructors on global vars not being run ?
Re: C++ Constructors on global vars not being run ?
- Subject: Re: C++ Constructors on global vars not being run ?
- From: Tommy Nordgren <email@hidden>
- Date: Mon, 24 Sep 2007 14:29:52 +0200
On 24 sep 2007, at 07.06, Peter Mulholland wrote:
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
Are you sure you have typed the constructor name correctly, in your
real code?
Enable all warnings and compile again. If you have mistyped a
constructor name,
you will get a warning that implicit return type of int is not
allowed by the current c++ standard.
----------------------------------
Skinheads are so tired of immigration, that they are going to move to
a country that don't accept immigrants!
Tommy Nordgren
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