• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

android/bindgen_cmd/25-Apr-2025-8147

codegen/25-Apr-2025-7,9146,371

ir/25-Apr-2025-15,21910,563

options/25-Apr-2025-2,1771,332

out/25-Apr-2025-11

patches/25-Apr-2025-9291

.cargo-checksum.jsonD25-Apr-20255 KiB11

Android.bpD25-Apr-20251.3 KiB5651

Cargo.tomlD25-Apr-20253 KiB156132

LICENSED25-Apr-20251.5 KiB3023

METADATAD25-Apr-2025637 2119

MODULE_LICENSE_BSD_LIKED25-Apr-20250

README.mdD25-Apr-20253.2 KiB9060

TEST_MAPPINGD25-Apr-2025287 1514

build.rsD25-Apr-20251 KiB3023

callbacks.rsD25-Apr-20256.8 KiB214115

cargo_embargo.jsonD25-Apr-2025226 1615

clang.rsD25-Apr-202571.2 KiB2,3481,723

deps.rsD25-Apr-20251.8 KiB6252

diagnostics.rsD25-Apr-20255.2 KiB190149

extra_assertions.rsD25-Apr-2025570 1812

features.rsD25-Apr-20259 KiB297243

lib.rsD25-Apr-202543.6 KiB1,3811,017

log_stubs.rsD25-Apr-20251 KiB3331

parse.rsD25-Apr-20251.5 KiB4219

regex_set.rsD25-Apr-20256.1 KiB205154

time.rsD25-Apr-20251.4 KiB5339

README.md

1[![crates.io](https://img.shields.io/crates/v/bindgen.svg)](https://crates.io/crates/bindgen)
2[![docs.rs](https://docs.rs/bindgen/badge.svg)](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