cbindgen
cbindgen copied to clipboard
Should `packed` attribute be used for enums with base integer type specified?
packed attribute (works in gcc and clang) for enums makes them to consume the minimal possible amount of bytes (and it works) and static analyser of Rust won't allow a value overflowing the type. Also it was proposed to allow use C++-style specification of base type, but it doesn't work in both Clang and gcc for now (they parse the source well (since C++ are treated there as a dialect of C), but enums are still 4 bytes in that case).
This has a benefit that enums are kept as enums.
You mean for enums with no base integer type specified? Those don't have a c++ compatible layout afaict.
Could you provide a sample rust code, with what we generate vs. what you expect?