4 ms·
This is a common pitfall in Rust wrappers for C libraries — they diligently copy the underlying library's typedefs as Rust's type aliases, but Rust doesn't hav
by pornel 2y ago
This is a common pitfall in Rust wrappers for C libraries — they diligently copy the underlying library's typedefs as Rust's type aliases, but Rust doesn't have the same implicit type conversions as C, which makes it a leaky abstraction.
In this case, I bet older/Intel version had a `typedef char BOOL` (i8 in Rust), and another version/platform upgraded that to `typedef _Bool BOOL` (bool in Rust).
In C that wasn't a breaking change, because C doesn't care if you compare `false` to 0, but Rust does.
Similarly, the plain `char` in C is allowed to be signed or unsigned depending on platform. Bindings to C libraries break when Rust programs mix `c_char` and `u8`, which are the same type on some platforms but not others.