This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
static const class member is undefined
- From: Erdi Chen <erdi at chen11 dot com>
- To: gcc at gnu dot org
- Date: Fri, 19 Dec 2003 23:04:12 -0800
- Subject: static const class member is undefined
G++ creates undefined symbols for static const class member variables
for the test code in the attached file. The version of gcc that I've
used is
gcc version 3.3.2 20031022 (Gentoo Linux 3.3.2-r3, propolice)
gcc 3.2.3 from Gentoo
gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1) Fedora Core 1
class Foo
{
public:
static const int a = 1;
static const int b = 2;
static const int c = 3;
static const int d = 4;
};
class Bar
{
public:
int bar(int n);
};
int Bar::bar(int n)
{
/* // this is okay
if (n != 0) return Foo::c;
else return Foo::d;
*/
//return Foo::c; // this is okay
return n != 0 ? Foo::c : Foo::d; // Foo::c and Foo::d undefined
}