[][src]Crate abibool

C ABI compatible boolean types

For most sane rust APIs, you should prefer bool in your interfaces and simply convert between types. However, bool isn't legal for all bit patterns, making it unusable for most FFI without conversions. For simple FFI, this isn't a problem, but C APIs writing arrays of BOOL or BOOLEAN, or structures containing these types, become problematic and require allocations and copies to avoid undefined behavior. Alternatively, you could just use integer types, that can obfuscate intent and result in bugs if multiple truthy-but-different values are directly compared when you expect boolean logic.

abibool typewinapi type
b8 / bool8BOOLEAN
b32 / bool32BOOL


pub use bool8 as b8;
pub use bool32 as b32;



8-bit boolean type that's ABI-compatible with Win32's BOOLEAN.


32-bit boolean type that's ABI-compatible with Win32's BOOL.