Since I know each element of an enum
has its own integer value, I tried this:
enum Foo {
Red = 0,
Blue = 1
};
int main(void) {
enum Foo bar = 2;
return 0;
}
And it... works. I looked further and I think it has the same minimum and maximum limits as int
(I started experiencing UB after INT_MAX
). At that point, isn't an enum
no better than a set of #define
s? I could also very well be wrong here, though.