Skip to content

Replacing native C types (Windows & Mac vs Linux) #1663

@Wodann

Description

@Wodann

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?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions