S
Sard
Hi,
Page 39 K&R2 says
'Although variables of enum types may be declared, compilers need not
check that what you store in such a variable is a valid value for the
enumeration'
gcc produces an error for the code below as I'm trying to assign a
pointer to char to the a variable of type colour. Is gcc going beyond
the call of duty? Why would the standard allow compilers to accept
such code?
#include <stdio.h>
#include <limits.h>
char* c=0;
enum colours {
Red,Blue
};
int main ()
{
enum colours purple =c ;
return 0;
}
Page 39 K&R2 says
'Although variables of enum types may be declared, compilers need not
check that what you store in such a variable is a valid value for the
enumeration'
gcc produces an error for the code below as I'm trying to assign a
pointer to char to the a variable of type colour. Is gcc going beyond
the call of duty? Why would the standard allow compilers to accept
such code?
#include <stdio.h>
#include <limits.h>
char* c=0;
enum colours {
Red,Blue
};
int main ()
{
enum colours purple =c ;
return 0;
}