Replacing native C types (Windows & Mac vs Linux) · Issue #1663 · rust-lang/rust-bindgen (original) (raw)

Bindgen nicely replaces occurrences of native C types with Rust types. For example:

#include <stdint.h>

typedef struct { const uint8_t b[16]; } MunGuid;

results in:

#[repr(C)] #[derive(Clone, Copy)] pub struct Guid { pub b: [u8; 16usize], }

It works. Lovely! One problem, once we run CI, it turns out that Ubuntu also generates this additional line

pub type __uint8_t = ::std::os::raw::c_uchar;

Even though bindgen is able to deduce that uint8_t is supposed to be u8, it still adds the __uint8_t type to the generated bindings.

One possible solution that I came up with to resolved this is to blacklist the __uint8_t type, but then bindgen stops automatically generating the #[derive(Clone, Copy)] attributes.

Is there a way to prevent the generation of "replaced" types?