R
Remco Poelstra
Hi,
I've the following piece of code:
enum {
PLAY,
STOP,
PAUSE
};
struct command {
unsigned char bytecode;
unsigned char arguments;
char *name;
};
struct command slink_commands[] = {
{0x00,0,"Play"},
{0x01,0,"Stop"},
{0x02,0,"Pause"},
};
int main(void) {
switch(1) {
case slink_commands[PLAY].bytecode:
break;
}
return 0;
}
My compiler now gives the warning that the case label doesn't reduce to
an integer constant. Why? The value is known at compile time...
Is this construction impossible, or can I tell my compiler some way that
it IS a constant?
(I'm using GCC 3.3.1, but I think it's more a C problem, than a GCC
problem, so I ask here. Sorry if this is the wrong place....)
Thanks in advance,
Remco Poelstra
I've the following piece of code:
enum {
PLAY,
STOP,
PAUSE
};
struct command {
unsigned char bytecode;
unsigned char arguments;
char *name;
};
struct command slink_commands[] = {
{0x00,0,"Play"},
{0x01,0,"Stop"},
{0x02,0,"Pause"},
};
int main(void) {
switch(1) {
case slink_commands[PLAY].bytecode:
break;
}
return 0;
}
My compiler now gives the warning that the case label doesn't reduce to
an integer constant. Why? The value is known at compile time...
Is this construction impossible, or can I tell my compiler some way that
it IS a constant?
(I'm using GCC 3.3.1, but I think it's more a C problem, than a GCC
problem, so I ask here. Sorry if this is the wrong place....)
Thanks in advance,
Remco Poelstra