This is the mail archive of the gcc@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]
Other format: [Raw text]

Re: Warning about int<-->enum conversions?


On 09 Jul 2004 00:19:40 -0300, Alexandre Oliva wrote:
> On Jul  8, 2004, Nicholas Nethercote <njn25@cam.ac.uk> wrote:
> 
> > Does GCC have a flag that would make it give warnings if an enum value
> > is mixed up with an int?
> 
> You're not mixing enums with ints.  According to the C standard, the
> type of enumerators (as opposed to the enumerate types themselves)
> *is* int.
> 
> >     void f ( int );
> 
> >     typedef enum { AA, BB, CC } T;
> 
> >     f (AA)           -- complain please
> >     int x = CC;      -- ditto
> 
> Given the enumerator type definition above, AA is just another way to
> spell 1, and CC is just another way to spell 3.

Shouldn't that be 0 and 2?

S>

-- 
9:42am up 20 days 17:16, 13 users, load average: 0.02, 0.22, 0.34
Registered Linux User #232457 | LFS ID 11703


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