[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Dumb C question
From: |
Sander Pool |
Subject: |
Re: [avr-gcc-list] Dumb C question |
Date: |
Fri, 16 Aug 2002 12:06:51 -0700 |
Ha! So then my method of (theotherting - this + 1) would be the way to go
anyway :-)
Sander
----- Original Message -----
From: "Jesper Hansen" <address@hidden>
To: "Larry Barello" <address@hidden>; "AVR GCC List"
<address@hidden>
Sent: Friday, August 16, 2002 10:57 AM
Subject: Re: [avr-gcc-list] Dumb C question
> You probably already know this, but anyway.....
>
> One easy way is :
>
> enum eMenuItem
> {
> D_this,
> D_that,
> D_TheOtherThing,
> D_Last_Enum
> }
>
> The size is then simply D_Last_Enum
>
> But as enum's can have init values like :
>
> enum eMenuItem
> {
> D_this = 50,
> D_that,
> D_TheOtherThing = 60,
> D_Last_Enum
> }
>
> D_Last_Enum would be wrong, so it's not foolproof.
>
> As far as I know, there's no way to do it with sizeof ( ) .
>
>
> /Jesper
>
>
> ----- Original Message -----
> From: "Larry Barello" <address@hidden>
> To: "AVR GCC List" <address@hidden>
> Sent: Friday, August 16, 2002 6:17 PM
> Subject: [avr-gcc-list] Dumb C question
>
>
> > I am slogging into the future and learning how to use "enums". Is there
> an
> > elegant way to find out how many items there are in a particular enum?
> i.e.
> >
> > enum eMenuItem
> > {
> > D_this,
> > D_that,
> > D_TheOtherThing
> > }
> >
> > If I say "sizeof(enum eMenuItem)" I just get 2, which of course is the
> size
> > of the enum.
> >
> > Cheers!
> >
> > avr-gcc-list at http://avr1.org
> >
>
>
> avr-gcc-list at http://avr1.org
>
avr-gcc-list at http://avr1.org
- FW: [avr-gcc-list] Dumb C question, J.C. Wren, 2002/08/31
- [avr-gcc-list] Dumb C question, Larry Barello, 2002/08/31
- Re: [avr-gcc-list] Dumb C question, Jesper Hansen, 2002/08/31
- Re: [avr-gcc-list] Dumb C question,
Sander Pool <=
- Re: [avr-gcc-list] Dumb C question, Jeff Dairiki, 2002/08/31
- Re: [avr-gcc-list] Dumb C question, Theodore A. Roth, 2002/08/31
- Re: [avr-gcc-list] Dumb C question, Mike Tsao, 2002/08/31
- Re: [avr-gcc-list] Dumb C question, Harald Kipp, 2002/08/31