CARVIEW |
Select Language
HTTP/2 200
server: GitHub.com
content-type: text/html; charset=utf-8
last-modified: Thu, 21 Aug 2025 08:34:19 GMT
access-control-allow-origin: *
etag: W/"68a6da0b-3bd5"
expires: Mon, 13 Oct 2025 17:50:16 GMT
cache-control: max-age=600
content-encoding: gzip
x-proxy-cache: MISS
x-github-request-id: 1764:788DD:20094:24FD5:68ED397F
accept-ranges: bytes
age: 0
date: Mon, 13 Oct 2025 17:40:17 GMT
via: 1.1 varnish
x-served-by: cache-bom-vanm7210042-BOM
x-cache: MISS
x-cache-hits: 0
x-timer: S1760377217.761880,VS0,VE296
vary: Accept-Encoding
x-fastly-request-id: eff3a38689143483da6e5bc776ce1d7f2a3c612d
content-length: 3706
Introduction - The bindgen User Guide
Introduction
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:
#![allow(unused)] fn main() { /* automatically generated by rust-bindgen 0.99.9 */ #[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); } }