-
Notifications
You must be signed in to change notification settings - Fork 707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
packed type cannot transitively contain a #[repr(align)]
type
#2179
Comments
I'm getting a similar error when trying to build https://github.com/nviennot/tinyusb-sys-rs.git I'm building with: I get these errors
Where the source looks like
|
Seen by the kernel as well at: https://lore.kernel.org/all/[email protected]/ struct alt_instr {
s32 instr_offset; /* original instruction */
s32 repl_offset; /* offset to replacement instruction */
union {
struct {
u32 cpuid: 16; /* CPUID bit set for replacement */
u32 flags: 16; /* patching control flags */
};
u32 ft_flgs;
};
u8 instrlen; /* length of original instruction */
u8 replacementlen; /* length of new instruction */
} __packed; |
Added to blocklist until closed by rust-lang/rust-bindgen#2179
Encountered the same problem when binding spdk. #include <stdint.h>
struct __attribute__((packed)) spdk_nvme_sgl_descriptor {
uint64_t address;
union {
struct {
uint8_t reserved[7];
uint8_t subtype : 4;
uint8_t type : 4;
} generic;
struct {
uint32_t length;
uint8_t reserved[3];
uint8_t subtype : 4;
uint8_t type : 4;
} unkeyed;
struct {
uint64_t length : 24;
uint64_t key : 32;
uint64_t subtype : 4;
uint64_t type : 4;
} keyed;
};
}; |
Any solution? |
Here is a simple breakdown of the actual issue at hand. It looks the rust compiler can't align and pack at the same time which is causing the issue. #[derive(Debug, Clone, Copy)]
#[repr(C, packed(2))]
struct PackedAlignedTest {
a: u32,
b: u16,
inner: PackedAlignedInnerTest,
}
#[derive(Debug, Clone, Copy)]
#[repr(C, align(2))]
struct PackedAlignedInnerTest {
c: u32,
d: u16,
}
fn main() {
let packed_aligned_test = PackedAlignedTest {
a: 0,
b: 1,
inner: PackedAlignedInnerTest {
c: 2,
d: 3
}
};
println!("{packed_aligned_test:#?}");
}
From what I can tell there was an oversight in this issue: rust-lang/rust#33158
This was never resolved and missed in review. |
Encountered the same problem when binding spdk.
|
o(╥﹏╥)o same problem when binding spdk, and another problem: error[E0428]: the name FP_NAN is defined multiple times
|
@xxxmailk the multiple |
Input C/C++ Header
Bindgen Invocation
Actual Results
Expected Results
compile successfully. If bitfields are removed and or packed is removed this work.
The text was updated successfully, but these errors were encountered: