Re: help: about enum

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

 



Hi Gaurav,

I think you should refer to ISO/IEC 14882 and/or ISO/IEC 9899.

An enum occupies the same space as a {signed|unsigned} int -- the natural
word size of the architecture of the machine in question.

The -fshort-enums option of GCC should only be used with due caution.

In C++, if you want the backing store of an enum-esque object to be a byte
(a {signed|unsigned|nonsigned} char), you can do something like this:

class Frobitz
{
    unsigned char m;
public:
    enum Type { foo, bar, quux, baz, fred, barney, xyzzy, plover };
    explicit Frobitz(Type in) : m(in) { }
    operator Type () const { return Type(m); }
};

HTH,
--Eljay



[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