#bindings #ffi #code-generation

build bindgen

Automatically generates Rust FFI bindings to C and C++ libraries

57 releases (25 breaking)

0.40.0 Sep 4, 2018
0.38.0 Aug 15, 2018
0.37.4 Jul 1, 2018
0.35.0 Mar 25, 2018
0.0.2 Nov 21, 2014

#6 in FFI

Download history 2610/week @ 2018-06-12 3628/week @ 2018-06-19 3639/week @ 2018-06-26 3334/week @ 2018-07-03 4633/week @ 2018-07-10 3210/week @ 2018-07-17 3152/week @ 2018-07-24 3401/week @ 2018-07-31 2928/week @ 2018-08-07 3295/week @ 2018-08-14 3961/week @ 2018-08-21 3879/week @ 2018-08-28 3641/week @ 2018-09-04

15,103 downloads per month
Used in 460 crates (240 directly)

BSD-3-Clause

1MB
19K SLoC

bindgen

impl period has been started! Join us at Gitter.im.

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

For example, given the C header doggo.h:

typedef struct Doggo {
    int many;
    char wow;
} Doggo;

void eleven_out_of_ten_majestic_af(Doggo* pupper);

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

/* automatically generated by rust-bindgen */

#[repr(C)]
pub struct Doggo {
    pub many: ::std::os::raw::c_int,
    pub wow: ::std::os::raw::c_char,
}

extern "C" {
    pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo);
}

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!

Dependencies

~4.5MB
~75K SLoC

  • build build.rs
  • dev diff 0.1
  • dev shlex 0.1