File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change 2
2
3
3
** ` bindgen ` automatically generates Rust FFI bindings to C and C++ libraries.**
4
4
5
- For example, given the C header ` cool .h` :
5
+ For example, given the C header ` doggo .h` :
6
6
7
7
``` c
8
- typedef struct CoolStruct {
9
- int x ;
10
- int y ;
11
- } CoolStruct ;
8
+ typedef struct Doggo {
9
+ int many ;
10
+ char wow ;
11
+ } Doggo ;
12
12
13
- void cool_function (int i, char c, CoolStruct * cs );
13
+ void eleven_out_of_ten_majestic_af (Doggo * pupper );
14
14
```
15
15
16
- `bindgen` produces Rust FFI code allowing you to call into the `cool ` library's
16
+ `bindgen` produces Rust FFI code allowing you to call into the `doggo ` library's
17
17
functions and use its types:
18
18
19
19
```rust
20
20
/* automatically generated by rust-bindgen */
21
21
22
22
#[repr(C)]
23
- pub struct CoolStruct {
24
- pub x : ::std::os::raw::c_int,
25
- pub y : ::std::os::raw::c_int ,
23
+ pub struct Doggo {
24
+ pub many : ::std::os::raw::c_int,
25
+ pub wow : ::std::os::raw::c_char ,
26
26
}
27
27
28
28
extern "C" {
29
- pub fn cool_function(i: ::std::os::raw::c_int,
30
- c: ::std::os::raw::c_char,
31
- cs: *mut CoolStruct);
29
+ pub fn eleven_out_of_ten_majestic_af(pupper: *mut Doggo);
32
30
}
33
31
```
34
32
You can’t perform that action at this time.
0 commit comments