Quick sanity check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

The compiler will not accept this. My thought is a pointer to member is a constant (an offset basically) but the compiler appears to disagree with me. I just want to make sure I'm not doing a silly syntax error. To me, it looks like 5.19 paragraph 6 says I can do this but I could easily be mistaken. FYI: IBM's xlC complains about it too.

class sge {
public:
    uint64_t address;
    uint32_t count;
    uint32_t flags;
};

class bitfield {
public:
    const uint32_t sge::*field = &sge::flags;
    static const uint32_t bit_start = 31;
    static const uint32_t bit_stop = 31;
};

g++ -o foo foo.C && ./foo
foo.C:14: error: 'sge::flags' cannot appear in a constant-expression
foo.C:14: error: `&' cannot appear in a constant-expression
foo.C:14: error: ISO C++ forbids initialization of member 'field'
foo.C:14: error: making 'field' static
foo.C:14: error: invalid in-class initialization of static data member of non-integral type 'const uint32_t sge::*'

Thank you,
Perry


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux