Re: In-class initialization of integral static const variables & Linker errors
Re: In-class initialization of integral static const variables & Linker errors
- Subject: Re: In-class initialization of integral static const variables & Linker errors
- From: Ethan Tira-Thompson <email@hidden>
- Date: Wed, 15 Jul 2009 19:08:02 -0700
Trying to build this with Xcode 3.1.3 on Mac OS X 10.5.7, I get the
following linker errors:
Undefined symbols:
You are getting this because you still need to define the storage for
the statics. Sometimes this isn't necessary, and I'm not sure why.
But you can put 'int const Foo::foo; int const Bar::bar;' somewhere in
a .cpp file, and the errors should go away.
I think initializing const variables in the class declaration, if it
is allowed by the ISO standard at all, is not supported by all
compilers.
I'm pretty sure it's in the standard that 'int' statics can be
initialized within the class declaration (in the header).
However no other types can be. I'm not sure why they do that
differentiation.
-Ethan
_______________________________________________
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