Connecting Tech Pros Worldwide Forums | Help | Site Map

__attribute__ ((mode(__byte__)))

JeromeArbezGindre@gmail.com
Guest
 
Posts: n/a
#1: Oct 9 '07
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


Mark Bluemel
Guest
 
Posts: n/a
#2: Oct 9 '07

re: __attribute__ ((mode(__byte__)))


JeromeArbezGindre@gmail.com wrote:
Quote:
Hi,
>
I would like to map an enum on a byte,so here is my code:
I don't know quite what you mean by this, or why you feel it's necessary
Quote:
enum my_enum {
A = 1,
B = 2,
} __attribute__ ((mode(__byte__))) ;

This, from the rapid websearch I've done, appears to be specific to GCC.
You'd do better posting to a GCC forum like gnu.gcc.help, I suspect.
JeromeArbezGindre@gmail.com
Guest
 
Posts: n/a
#3: Oct 9 '07

re: __attribute__ ((mode(__byte__)))


On Oct 9, 3:04 pm, Mark Bluemel <mark_blue...@pobox.comwrote:
Quote:
JeromeArbezGin...@gmail.com wrote:
Quote:
I would like to map an enum on a byte,so here is my code:
>
I don't know quite what you mean by this, or why you feel it's necessary
This enum have to be mapped on a hardware register.
Quote:
This, from the rapid websearch I've done, appears to be specific to GCC.
You'd do better posting to a GCC forum like gnu.gcc.help, I suspect.
Sorry for the noise.

Thanks.


Closed Thread