Automatically generates Rust FFI bindings to C and C++ libraries.
bindgen is a Rust tool that automatically generates Foreign Function Interface (FFI) bindings to C and some C++ libraries. It parses C/C++ header files and produces corresponding Rust code with proper type definitions and function declarations, solving the problem of manual and error-prone FFI binding creation. This enables Rust developers to safely interoperate with existing native codebases.
Rust developers who need to interface with C or C++ libraries, particularly those working on systems programming, embedded systems, or integrating with existing native codebases.
Developers choose bindgen because it automates the tedious process of creating FFI bindings, reduces human error, and provides accurate Rust representations of C/C++ types and functions. Its integration with libclang ensures reliable parsing of complex headers.
Automatically generates Rust FFI bindings to C (and some C++) libraries.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Parses C/C++ headers and produces accurate Rust code automatically, as demonstrated with the doggo.h example, eliminating manual and error-prone binding creation.
Supports customization through environment variables like BINDGEN_EXTRA_CLANG_ARGS for cross-compilation, allowing adaptation to different targets and sysroots.
Uses libclang for reliable parsing of complex header files, ensuring type safety and accurate code generation, as noted in the key features.
Handles some C++ constructs in addition to C, enabling integration with C++ libraries beyond plain C interfaces.
Only supports 'some C++ constructs,' as admitted in the description, making it unsuitable for full C++ feature sets like templates or complex inheritance.
Requires libclang, which can be challenging to install and configure, especially in cross-compilation or restricted environments, as hinted in the environment variables section.
The README states no minimum supported Rust version bump policy, so MSRV may increase unexpectedly, leading to potential breaking changes without warning.