|
Name |
|
Date |
Size |
#Lines |
LOC |
| .. | | - | - |
| android/bindgen_cmd/ | | 25-Apr-2025 | - | 81 | 47 |
| codegen/ | | 25-Apr-2025 | - | 7,914 | 6,371 |
| ir/ | | 25-Apr-2025 | - | 15,219 | 10,563 |
| options/ | | 25-Apr-2025 | - | 2,177 | 1,332 |
| out/ | | 25-Apr-2025 | - | 1 | 1 |
| patches/ | | 25-Apr-2025 | - | 92 | 91 |
| .cargo-checksum.json | D | 25-Apr-2025 | 5 KiB | 1 | 1 |
| Android.bp | D | 25-Apr-2025 | 1.3 KiB | 56 | 51 |
| Cargo.toml | D | 25-Apr-2025 | 3 KiB | 156 | 132 |
| LICENSE | D | 25-Apr-2025 | 1.5 KiB | 30 | 23 |
| METADATA | D | 25-Apr-2025 | 637 | 21 | 19 |
| MODULE_LICENSE_BSD_LIKE | D | 25-Apr-2025 | 0 | | |
| README.md | D | 25-Apr-2025 | 3.2 KiB | 90 | 60 |
| TEST_MAPPING | D | 25-Apr-2025 | 287 | 15 | 14 |
| build.rs | D | 25-Apr-2025 | 1 KiB | 30 | 23 |
| callbacks.rs | D | 25-Apr-2025 | 6.8 KiB | 214 | 115 |
| cargo_embargo.json | D | 25-Apr-2025 | 226 | 16 | 15 |
| clang.rs | D | 25-Apr-2025 | 71.2 KiB | 2,348 | 1,723 |
| deps.rs | D | 25-Apr-2025 | 1.8 KiB | 62 | 52 |
| diagnostics.rs | D | 25-Apr-2025 | 5.2 KiB | 190 | 149 |
| extra_assertions.rs | D | 25-Apr-2025 | 570 | 18 | 12 |
| features.rs | D | 25-Apr-2025 | 9 KiB | 297 | 243 |
| lib.rs | D | 25-Apr-2025 | 43.6 KiB | 1,381 | 1,017 |
| log_stubs.rs | D | 25-Apr-2025 | 1 KiB | 33 | 31 |
| parse.rs | D | 25-Apr-2025 | 1.5 KiB | 42 | 19 |
| regex_set.rs | D | 25-Apr-2025 | 6.1 KiB | 205 | 154 |
| time.rs | D | 25-Apr-2025 | 1.4 KiB | 53 | 39 |
README.md
1[](https://crates.io/crates/bindgen)
2[](https://docs.rs/bindgen/)
3
4# `bindgen`
5
6**`bindgen` automatically generates Rust FFI bindings to C (and some C++) libraries.**
7
8For example, given the C header `doggo.h`:
9
10```c
11typedef struct Doggo {
12 int many;
13 char wow;
14} Doggo;
15
16void eleven_out_of_ten_majestic_af(Doggo* pupper);
17```
18
19`bindgen` produces Rust FFI code allowing you to call into the `doggo` library's
20functions and use its types:
21
22```rust
23/* automatically generated by rust-bindgen 0.99.9 */
24
25#[repr(C)]
26pub struct Doggo {
27 pub many: ::std::os::raw::c_int,
28 pub wow: ::std::os::raw::c_char,
29}
30
31extern "C" {
32 pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo);
33}
34```
35
36## Users Guide
37
38[ Read the `bindgen` users guide here! ](https://rust-lang.github.io/rust-bindgen)
39
40## MSRV
41
42The `bindgen` minimum supported Rust version is **1.60.0**.
43
44The `bindgen-cli` minimum supported Rust version is **1.64.0**.
45
46No MSRV bump policy has been established yet, so MSRV may increase in any release.
47
48The MSRV is the minimum Rust version that can be used to *compile* each crate. However, `bindgen` and `bindgen-cli` can generate bindings that are compatible with Rust versions below the current MSRV.
49
50Most of the time, the `bindgen-cli` crate will have a more recent MSRV than `bindgen` as crates such as `clap` require it.
51
52## API Reference
53
54[API reference documentation is on docs.rs](https://docs.rs/bindgen)
55
56## Environment Variables
57
58In addition to the [library API](https://docs.rs/bindgen) and [executable command-line API][bindgen-cmdline],
59`bindgen` can be controlled through environment variables.
60
61End-users should set these environment variables to modify `bindgen`'s behavior without modifying the source code of direct consumers of `bindgen`.
62
63- `BINDGEN_EXTRA_CLANG_ARGS`: extra arguments to pass to `clang`
64 - Arguments are whitespace-separated
65 - Use shell-style quoting to pass through whitespace
66 - Examples:
67 - Specify alternate sysroot: `--sysroot=/path/to/sysroot`
68 - Add include search path with spaces: `-I"/path/with spaces"`
69- `BINDGEN_EXTRA_CLANG_ARGS_<TARGET>`: similar to `BINDGEN_EXTRA_CLANG_ARGS`,
70 but used to set per-target arguments to pass to clang. Useful to set system include
71 directories in a target-specific way in cross-compilation environments with multiple targets.
72 Has precedence over `BINDGEN_EXTRA_CLANG_ARGS`.
73
74Additionally, `bindgen` uses `libclang` to parse C and C++ header files.
75To modify how `bindgen` searches for `libclang`, see the [`clang-sys` documentation][clang-sys-env].
76For more details on how `bindgen` uses `libclang`, see the [`bindgen` users guide][bindgen-book-clang].
77
78## Releases
79
80We don't follow a specific release calendar, but if you need a release please
81file an issue requesting that (ping `@emilio` for increased effectiveness).
82
83## Contributing
84
85[See `CONTRIBUTING.md` for hacking on `bindgen`!](./CONTRIBUTING.md)
86
87[bindgen-cmdline]: https://rust-lang.github.io/rust-bindgen/command-line-usage.html
88[clang-sys-env]: https://github.com/KyleMayes/clang-sys#environment-variables
89[bindgen-book-clang]: https://rust-lang.github.io/rust-bindgen/requirements.html#clang
90