[Top][All Lists]

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

Re: [avr-gcc-list] Dumb C question

From: Mike Tsao
Subject: Re: [avr-gcc-list] Dumb C question
Date: Fri, 16 Aug 2002 11:18:45 -0700

Easiest way is to make a constant that happens to live at the end of the

enum eMenuItem
    D_this = 0,
    K_NUM_MENU_ITEMS /* This must remain at end of list */

Obviously this is fragile (other developers won't read your comments and
will put the next item at the very end of the list), and it requires the
first one to start at zero (though all true C programmers make all
enumerations start at zero ;), but it works.

----- Original Message -----
From: "Larry Barello" <address@hidden>
To: "AVR GCC List" <address@hidden>
Sent: Friday, August 16, 2002 9:17 AM
Subject: [avr-gcc-list] Dumb C question

> I am slogging into the future and learning how to use "enums".  Is there
> elegant way to find out how many items there are in a particular enum?
> enum eMenuItem
> {
>     D_this,
>     D_that,
>     D_TheOtherThing
> }
> If I say "sizeof(enum eMenuItem)" I just get 2, which of course is the
> of the enum.
> Cheers!
> avr-gcc-list at http://avr1.org

avr-gcc-list at http://avr1.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]