On Tue, Nov 22, 2022 at 4:38 PM Bartosz Golaszewski <brgl@xxxxxxxx> wrote: > > --- > The expression that defines the value of an enumeration constant shall > be an integer constant expression that has a value representable as an > int. > --- > > and virtually all compilers store enum variables as signed integers, I don't think this is true. Both GCC and Clang seem to pick an unsigned one if possible (for the enum, not the constants), e.g. https://godbolt.org/z/6zjzMdP3T. I assume bindgen is using the one decided by clang. Note that the quote of the standard is a constraint, i.e. the values of the constants need to fit in an `int` (and the compiler is required to issue a diagnostic if they don't, under `-Wpedantic` in GCC/Clang). > As enums are naturally signed integers in the C world - can we somehow > make bindgen default to c_int for all enum types? This would be https://github.com/rust-lang/rust-bindgen/issues/1966, where it has been suggested as an option (as well as the fact that the constants are not being generated as `c_int`). Cheers, Miguel