static const class member is undefined
Erdi Chen
erdi@chen11.com
Sun Dec 21 14:52:00 GMT 2003
Perhaps I wasn't specific enough: I am talking about static const class
member variables of integral types. ISO C++ allows these variables to be
initialized inside the class definition. Either way, it would be a bug
since only very specific code would cause this error: "return n != 0 ?
Foo::c : Foo::d;". Other use of the variables, such as "return Foo::c;",
is okay. Gcc generates a literal for the latter but a variable reference
for the former.
>> G++ creates undefined symbols for static const class member variables
>> for the test code in the attached file.
>
> It's ISO C++: class static data members must have a definition outside
> the class definition, even if they are const.
>
> --
> Eric Botcazou
>
More information about the Gcc
mailing list