mirror of
https://github.com/openharmony/third_party_rust_bindgen.git
synced 2026-08-27 05:31:15 -04:00
f8b7761ba35fb74b6650196dccbea348d5e36d9b
The objetive-c template type params were handled as Typedefs so every interface generated its own, clashing in the namespace. This now maps them to id.
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
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%