Re: Question about "enums"
- From: "Bill Pursell" <bill.pursell@xxxxxxxxx>
- Date: 30 Apr 2006 01:32:17 -0700
Ian Collins wrote:
Bill Pursell wrote:
Ian Collins wrote:But not with the following, which I've always considered a huge hole in
Assigning any other value to <an enum type> is undefined. Unfortunately C
compilers don't regard this as an error, which renders enums little more
than symbolic constants.
gcc gives a warning when you do a switch on an enum type, indicating
that you have failed to explicitely specify behavior for any of the
listed cases. I find that very useful.
the C standard.
enum loop { NO, YES};
enum loop okloop=YES;
void f( enum loop v )
{
}
int main(void)
{
f( 42 );
okloop = 42;
return 0;
}
Agreed. I've never written a compiler, but it strikes me that that
should be a fairly simple warning to emit. Does anyone know why such
warnings are not given?
.
- References:
- Question about "enums"
- From: mdh
- Re: Question about "enums"
- From: Ian Collins
- Re: Question about "enums"
- From: mdh
- Re: Question about "enums"
- From: Ian Collins
- Re: Question about "enums"
- From: Bill Pursell
- Re: Question about "enums"
- From: Ian Collins
- Question about "enums"
- Prev by Date: Re: Question about "enums"
- Next by Date: Re: first program with pointers to structures and realloc....
- Previous by thread: Re: Question about "enums"
- Next by thread: Re: Question about "enums"
- Index(es):
Relevant Pages
|
|