Automatically generates Rust FFI bindings to C (and some C++) libraries.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rigel Kent 41db162348 switch defaults from generating unstable Rust to generating stable Rust 1 year ago
.github Fix issue template typo 1 year ago
bindgen-integration switch defaults from generating unstable Rust to generating stable Rust 1 year ago
book switch defaults from generating unstable Rust to generating stable Rust 1 year ago
ci Run tests with RUST_BACKTRACE=1 1 year ago
src switch defaults from generating unstable Rust to generating stable Rust 1 year ago
tests switch defaults from generating unstable Rust to generating stable Rust 1 year ago
.gitattributes Add a Stylo bindings sanity test 2 years ago
.gitignore Fix .gitignore and extra crates' Cargo.lock files 2 years ago
.travis.yml Allow asserting expectations across different libclang versions 1 year ago
CONTRIBUTING.md Add some information about PRs and review to CONTRIBUTING.md 1 year ago
Cargo.lock Version bump to get insta-published. 1 year ago
Cargo.toml Version bump to get insta-published. 1 year ago
LICENSE fix build and add license 5 years ago
README.md Add the `bindgen` Users Guide 2 years ago
build.rs Add a way to get the target triple, and do our best guess at it until we have proper clang support. 1 year ago
example-graphviz-ir.png Update the example graphviz image 2 years ago
rustfmt.toml Manual fixups, some of them pretty lame, and don't let rustfmt rewrap comments. 2 years ago

README.md

bindgen

bindgen automatically generates Rust FFI bindings to C and C++ libraries.

For example, given the C header cool.h:

typedef struct CoolStruct {
    int x;
    int y;
} CoolStruct;

void cool_function(int i, char c, CoolStruct* cs);

bindgen produces Rust FFI code allowing you to call into the cool library’s functions and use its types:

/* automatically generated by rust-bindgen */

#[repr(C)]
pub struct CoolStruct {
    pub x: ::std::os::raw::c_int,
    pub y: ::std::os::raw::c_int,
}

extern "C" {
    pub fn cool_function(i: ::std::os::raw::c_int,
                         c: ::std::os::raw::c_char,
                         cs: *mut CoolStruct);
}

Users Guide

📚 Read the bindgen users guide here! 📚

API Reference

API reference documentation is on docs.rs

Contributing

See CONTRIBUTING.md for hacking on bindgen!