I have declared and initialized a struct at the top of the file like so:
struct myDataTypes {
int INT;
int DOUBLE;
int FLOAT;
} types = {0,1,2};
When I try to use types.INT
in a case
of a switch
, I get the compiler error that the case label does not reduce to an integer constant
. Is that it, struct members cannot work as integer constants?
BTW, I'm using a struct for this rather than an enum because enums pollute the global namespace. I prefer the way I can hide INT
, DOUBLE
, FLOAT
in a struct.