| |||
| Home > Compiler Command-line Options > ‑‑interface_enums_are_32_bit | |||
This option helps to provide compatibility between external code interfaces, with regard to the size of enumerated types.
It is not possible to link an object file compiled with --enum_is_int,
with another object file that is compiled without --enum_is_int.
The linker is unable to determine whether or not the enumerated
types are used in a way that affects the external interfaces, so
on detecting these build differences, it produces a warning or an
error. You can avoid this by compiling with --interface_enums_are_32_bit.
The resulting object file can then be linked with any other object file,
without the linker-detected conflict that arises from different
enumeration type sizes.
When you use this option, you are making a promise to the
compiler that all the enumerated types used in your external interfaces
are 32 bits wide. For example, if you ensure that every enum you
declare includes at least one value larger than 2 to the power of
16, the compiler is forced to make the enum 32
bits wide, whether or not you use --enum_is_int.
It is up to you to ensure that the promise you are making to the
compiler is true. (Another method of satisfying this condition is
to ensure that you have no enums in your external
interface.)