diff options
author | Nick Fitzgerald <fitzgen@gmail.com> | 2017-07-13 14:44:27 -0700 |
---|---|---|
committer | Nick Fitzgerald <fitzgen@gmail.com> | 2017-07-13 14:44:27 -0700 |
commit | cfdcda6f9132e4ab112f49d00a1a834ce9c05644 (patch) | |
tree | 78877ff90e50dbb0089d6c0cbf1ff6c73aa7ed09 | |
parent | f0b343235fe14bcf24dd9ad852c0cbd7eaaefcd0 (diff) |
11/10 MAJESTIC AF
-rw-r--r-- | README.md | 24 |
1 files changed, 11 insertions, 13 deletions
@@ -2,33 +2,31 @@ **`bindgen` automatically generates Rust FFI bindings to C and C++ libraries.** -For example, given the C header `cool.h`: +For example, given the C header `doggo.h`: ```c -typedef struct CoolStruct { - int x; - int y; -} CoolStruct; +typedef struct Doggo { + int many; + char wow; +} Doggo; -void cool_function(int i, char c, CoolStruct* cs); +void eleven_out_of_ten_majestic_af(Doggo* pupper); ``` -`bindgen` produces Rust FFI code allowing you to call into the `cool` library's +`bindgen` produces Rust FFI code allowing you to call into the `doggo` library's functions and use its types: ```rust /* automatically generated by rust-bindgen */ #[repr(C)] -pub struct CoolStruct { - pub x: ::std::os::raw::c_int, - pub y: ::std::os::raw::c_int, +pub struct Doggo { + pub many: ::std::os::raw::c_int, + pub wow: ::std::os::raw::c_char, } extern "C" { - pub fn cool_function(i: ::std::os::raw::c_int, - c: ::std::os::raw::c_char, - cs: *mut CoolStruct); + pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo); } ``` |