This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]