The size of a C enum is not specified by the standard; compilers can choose whatever is appropriate. On my platform this is 4 octets (32 bits), so the LSBs of the enum are wiped. This changes with the positioning of the enum in the Cap'n Proto definition; in an even numbered position, it's fine.
I have a Cap'n Proto schema that looks like:
The enum type is represented as a C enum. But the generated code treats it as interchangeable with the
UInt16
type:The size of a C enum is not specified by the standard; compilers can choose whatever is appropriate. On my platform this is 4 octets (32 bits), so the LSBs of the enum are wiped. This changes with the positioning of the enum in the Cap'n Proto definition; in an even numbered position, it's fine.