Don't use enums in function signatures or as struct fields
Interfacing with C libraries that use enums in their public interface from non-C languages is hard.
On almost all gcc targets, enums start with the layout of int
and then grow to long
if any of their fields do not fit in int
. However, on the Hexagon target enums start as char
and then grow as necessary. MSVC always uses int
and silently truncates variants if they don't fit. Robustly wrapping these enums therefore requires us to determine their layout at compile time.
All of this can be avoided by replacing enums in the public interface by uint32_t
or similar. Of course, this does not mean that you cannot use enums to define the values of the variants.
This is not: https://gitlab.freedesktop.org/libinput/libei/-/blob/befbf2005c3da4a94e518ead5703ee162008f31d/src/libeis.h#L450-452