abibool

C ABI compatible boolean types

Latest version: 0.5.3 registry icon
Maintenance score
0
Safety score
0
Popularity score
71
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
0.5.3 0 0 0 0 0
0.5.2 0 0 0 0 0
0.5.1 0 0 0 0 0
0.5.0 0 0 0 0 0

Stability
Latest release:

0.5.3 - This version may not be safe as it has not been updated for a long time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

Apache-2.0   -   Apache License 2.0

Not a wildcard

Not proprietary

OSI Compliant


MIT   -   MIT License

Not a wildcard

Not proprietary

OSI Compliant



abibool - C ABI compatible boolean types

GitHub crates.io docs.rs License Build Status

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 value are directly compared when you expect boolean logic.

Type Map

Note that this is incredibly system specific. E.g. BOOL for windows is 4 bytes, but for OS X it's 1 byte... probably.
When using abibool to write FFI crates, you may wish to cc a bunch of static_asserts in a build script to validate the size of your underlying C types.

C / C++ type abibool type notes
bool (C++) varies Often 1 byte, but sometimes 4 or worse
_Bool (C99 / stdbool.h) varies Often 1 byte, but sometimes 4 or worse
BOOLEAN (Win32) b8 / bool8
BOOL (Win32) b32 / bool32
BOOL (OS X / objc.h) b8 / bool8 ? Typically signed char, but sometimes bool or unsigned char
jboolean (Java / JNI) b8 / bool8

References

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.