mirror of
https://github.com/openharmony/third_party_rust_bindgen.git
synced 2026-07-20 22:56:53 -04:00
8473e70edee03b79b9c3bfe8adc2cd5dfff58bb3
Alignment arrays are not needed anymore, since we have repr(align).
bindgen
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
Description
一个自动生成 C 和 C++ 库 Rust 绑定的工具。 | A tool that automatically generates Rust bindings for C and C++ libraries.
Languages
Rust
97.8%
Python
1.4%
Shell
0.5%
C
0.2%
Batchfile
0.1%