This is the mail archive of the gcc-help@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]

Re: number enum elements


Bart Vanherck (herckb@se.bel.alcatel.be) wrote:
>
> how can I determine the number of elements in a enum
> mode ?
>
> enum  element { one , two ,three , five }

The usual trick is to declare an extra enum constant:

	enum element { one, two, three, five, NUM_ELEMENT };

Of course, that doesn't work if you explicitly provide values for any of
the enumeration constants.

-Larry Jones

I suppose if I had two X chromosomes, I'd feel hostile too. -- Calvin


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