rust-bindgen
rust-bindgen copied to clipboard
Automatically generates Rust FFI bindings to C (and some C++) libraries.
Related https://github.com/rust-lang/rust-bindgen/issues/1768, https://github.com/ghpr-asia/wsdf/issues/18 I think this would at least make analyzing this failure easier and based on the wsdf issue it seems that in some cases including another file also...
### Input C/C++ Header ```C++ /* Arcseconds to radians */ /* Radians to arcseconds */ #define DR2AS (206264.8062470963551564734) /* Arcseconds to radians */ #define DAS2R (4.848136811095359935899141e-6) /* Seconds of time...
Fixes #2845. Wrapping the generated array in a struct ensures that it is passed in an FFI-safe way. This does assume that the calling convention for structs is only dependent...
### Input C/C++ Header ```C++ struct foo { int a; long b; } __attribute__((packed, aligned(8))); ``` ### Bindgen Invocation ```Rust let bindings = bindgen::Builder::default() .header("wrapper.h") .parse_callbacks(Box::new(bindgen::CargoCallbacks::new())) .generate() .expect("Unable to generate...
I have several (5-10+) ~6000 line headers I want to generate bindings for. (These headers have a lot of the same types but I post-process the bindings from bindgen to...
`header.hpp`: ```c++ using example_type = std::function; ``` `bindgen` invocation: ```rust let bindings = bindgen::Builder::default() .header("header.hpp") .opaque_type("std::.*") .whitelist_type("example_type") .rust_target(bindgen::RustTarget::Nightly) .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .generate() .expect("Unable to generate bindings"); ``` Output binding: ```rust pub type...
### Input C/C++ Header ```C++ #define UAVCAN_PROTOCOL_GETNODEINFO_REQUEST_SIGNATURE (0xEE468A8121C46A9EULL) ``` ### Bindgen Invocation ```Rust let bindings = bindgen::Builder::default() .clang_arg("-Iexternal/libcanard") .header("wrapper.h") .generate() .expect("Unable to generate bindings"); ``` ```rs pub const UAVCAN_PROTOCOL_GETNODEINFO_REQUEST_SIGNATURE: i64...
I am happily using bindgen to link Rust to a C++ library, and it works great... except when compiling for the MSVC target (that is `i686-pc-windows-msvc` or `x86_64-pc-windows-msvc`), that my...
Consider the following C++ code: ``` #include "stdio.h" class Inner { public: Inner(); ~Inner(); }; Inner::Inner() { printf("constructing Inner\n"); } Inner::~Inner() { printf("destructing Inner\n"); } class Outer { Inner in;...
### Input C/C++ Header ```C++ template class Test { enum class Enum { One, Two }; }; ``` ### Bindgen Invocation Tested both with the current release and current `main`:...