Description
Hello bindgen
team! I am having some issues with bindings generated from Windows USB headers defined in ucxusbdevice.h
. Here is a link to a minimal repro I've been able to generate: https://github.com/leon-xd/rust-repros/tree/main/crates/bindgen-size-overflow. I copied relevant definitions and made a new header file that is able to reproduce the issue.
There are four structs that are not generated with the right definition. It seems like they are generated as opaque, but do not have the correct size. In switching from bindgen
0.69.* to 0.71.0 we were able to detect this issue with the introduction of compile time error checking.
A (preferably reduced) C/C++ header file that reproduces the issue
The bindgen flags used to reproduce the issue with the header file
Builder::default()
is used here: https://github.com/leon-xd/rust-repros/blob/main/crates/bindgen-size-overflow/build.rs
The expected bindgen output
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _USBDEVICE_ABORTIO {
pub _address: _USBDEVICE_MGMT_HEADER,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of _USBDEVICE_ABORTIO"][::std::mem::size_of::<_USBDEVICE_ABORTIO>() - 24usize];
["Alignment of _USBDEVICE_ABORTIO"][::std::mem::align_of::<_USBDEVICE_ABORTIO>() - 8usize];
};
The actual bindgen output
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _USBDEVICE_ABORTIO {
pub _address: u8,
}
#[allow(clippy::unnecessary_operation, clippy::identity_op)]
const _: () = {
["Size of _USBDEVICE_ABORTIO"][::std::mem::size_of::<_USBDEVICE_ABORTIO>() - 24usize];
["Alignment of _USBDEVICE_ABORTIO"][::std::mem::align_of::<_USBDEVICE_ABORTIO>() - 8usize];
};
The debugging logs generated when running bindgen on this testcase
- The output of cargo build -vvv is here: logs.txt