- Notifications
You must be signed in to change notification settings - Fork770
Automatically generates Rust FFI bindings to C (and some C++) libraries.
License
rust-lang/rust-bindgen
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
bindgen automatically generates Rust FFI bindings to C (and some C++) libraries.
For example, given the C headerdoggo.h:
typedefstructDoggo {intmany;charwow;}Doggo;voideleven_out_of_ten_majestic_af(Doggo*pupper);
bindgen produces Rust FFI code allowing you to call into thedoggo library'sfunctions and use its types:
/* automatically generated by rust-bindgen 0.99.9 */#[repr(C)]pubstructDoggo{pubmany:::std::os::raw::c_int,pubwow:::std::os::raw::c_char,}extern"C"{pubfneleven_out_of_ten_majestic_af(pupper:*mutDoggo);}
📚 Read thebindgen users guide here! 📚
Thebindgen minimum supported Rust version is1.70.0.
Thebindgen-cli minimum supported Rust version is1.70.0.
No MSRV bump policy has been established yet, so MSRV may increase in any release.
The MSRV is the minimum Rust version that can be used tocompile each crate. However,bindgen andbindgen-cli can generate bindings that are compatible with Rust versions below the current MSRV.
Most of the time, thebindgen-cli crate will have a more recent MSRV thanbindgen as crates such asclap require it.
API reference documentation is on docs.rs
In addition to thelibrary API andexecutable command-line API,bindgen can be controlled through environment variables.
End-users should set these environment variables to modifybindgen's behavior without modifying the source code of direct consumers ofbindgen.
BINDGEN_EXTRA_CLANG_ARGS: extra arguments to pass toclang- Arguments are whitespace-separated
- Use shell-style quoting to pass through whitespace
- Examples:
- Specify alternate sysroot:
--sysroot=/path/to/sysroot - Add include search path with spaces:
-I"/path/with spaces"
- Specify alternate sysroot:
BINDGEN_EXTRA_CLANG_ARGS_<TARGET>: similar toBINDGEN_EXTRA_CLANG_ARGS,but used to set per-target arguments to pass to clang. Useful to set system includedirectories in a target-specific way in cross-compilation environments with multiple targets.Has precedence overBINDGEN_EXTRA_CLANG_ARGS.
Additionally,bindgen useslibclang to parse C and C++ header files.To modify howbindgen searches forlibclang, see theclang-sys documentation.For more details on howbindgen useslibclang, see thebindgen users guide.
We don't follow a specific release calendar, but if you need a release pleasefile an issue requesting that (ping@emilio for increased effectiveness).
About
Automatically generates Rust FFI bindings to C (and some C++) libraries.
Topics
Resources
License
Contributing
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.