Code: Select all
sizeof(enum MyEnum) == 1
Why does this happen without explicit -fshort-enums option? From gcc user's manual:
The warning is important. How the libraries have been compiled (newlib and I don't know what else). If they have been compiled without that option, the application that I wrote will be incompatible with them.-fshort-enums
Allocate to an enum type only as many bytes as it needs for the declared range of possible values. Specifically, the enum type is equivalent to the smallest integer type that has enough room.
Warning: the -fshort-enums switch causes GCC to generate code that is not binary compatible with code generated without that switch. Use it to conform to a non-default application binary interface.