J
JeromeArbezGindre
Hi,
I would like to map an enum on a byte,so here is my code:
enum my_enum {
A = 1,
B = 2,
} __attribute__ ((mode(__byte__))) ;
int is_A (enum my_enum my_val)
{
return (my_val == A) ;
}
When compiled, I have the following:
cc -c -o toto.o toto.c
toto.c: In function 'is_A':
toto.c:10: warning: comparison is always false due to limited range of
data type
I do not have any problem when i transfrom is_A :
int is_A (unsigned char my_val)
{
return (my_val == A) ;
}
So, muy question is :
Is there a correct way to declare an enum fo map it on a byte.
Thanks
Jérôme
I would like to map an enum on a byte,so here is my code:
enum my_enum {
A = 1,
B = 2,
} __attribute__ ((mode(__byte__))) ;
int is_A (enum my_enum my_val)
{
return (my_val == A) ;
}
When compiled, I have the following:
cc -c -o toto.o toto.c
toto.c: In function 'is_A':
toto.c:10: warning: comparison is always false due to limited range of
data type
I do not have any problem when i transfrom is_A :
int is_A (unsigned char my_val)
{
return (my_val == A) ;
}
So, muy question is :
Is there a correct way to declare an enum fo map it on a byte.
Thanks
Jérôme