rust-bindgen
rust-bindgen copied to clipboard
Automatically generates Rust FFI bindings to C (and some C++) libraries.
I don't know if this is a bug, or it is by design. ### Input C/C++ Header A minimal header ```C++ typedef enum cudaError_enum { CUDA_SUCCESS = 0, CUDA_ERROR_INVALID_VALUE =...
### Input C/C++ Header ```C++ #define A 1 #define B 2 #undef A #define A 2 #undef B #define B 1 ``` ### Bindgen Invocation ```Rust bindgen::Builder::default() .header("input.h") .generate() .unwrap()...
When a C struct has both `packed` and `aligned(N)` attributes, in some cases bindgen generates a Rust struct with a `packed(N)` attribute only that has the correct ABI. (Note, I'm...
### Input C/C++ Header ```C++ enum long_prefix_to_remove_foo { BAR = 0 }; int long_prefix_to_remove_bar(); ``` There is no way to implement `ParseCallbacks::item_name` that can follow different naming logic for these...
All ways of interop with C enums unfortunately have some downsides. `constified-enum`, `constified-enum-module`, `newtype-enum`, and `bitfield-enum` can't be matched exhaustively: using the below demo, for example: ```rust match some_foo {...
In the header files I am trying to make bindings for, some constants are defined like this: ```c #define kOfxStatFailed ((int)1) #define kOfxStatErrFatal ((int)2) // ... ``` Can this pattern...
When creating bindings for a struct with bitfields the accessor functions that are created take an immutable receiver (`&self`). This is a problem if the underlying type is used by...
Much like `clang_args`, a helper for adding multiple headers in a chained builder expression. The signature should be: ```rust pub fn headers(self, headers: I) -> Self where I::Item: Into ```
We would like to wrap all our calls into the FFI boundary with a standard piece of code. In particular. we would like to use [cee_scape](https://crates.io/crates/cee-scape) to solve some `long_jmp`...
bindgen would generate the incorrect binding for the C++ member function `Dims getBindingDimensions(int32_t bindingIndex) const;`. It would generate: ```rust extern "C" { #[link_name = "\u{1}?getBindingDimensions@ICudaEngine@nvinfer1@@QEBA?AVDims32@2@H@Z"] pub fn ICudaEngine_getBindingDimensions( this: *const...