This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: number enum elements
- To: help-gcc at gnu dot org
- Subject: Re: number enum elements
- From: scjones at thor dot sdrc dot com (Larry Jones)
- Date: 21 Oct 1999 20:30:28 GMT
- Distribution: world
- Newsgroups: gnu.gcc.help
- Organization: Structural Dynamics Research Corp.
- References: <380DC142.F6CB7742@se.bel.alcatel.be>
- Reply-To: larry dot jones at sdrc dot com
- Xref: wodc7nx0 gnu.gcc.help:1527
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