Closed
Description
Input C/C++ Header
class A {
double X;
int Y;
};
class B : public A {
int Z;
};
Bindgen Invocation
bindgen test.hpp
Actual Results
ERROR:bindgen::codegen::struct_layout: Calculated wrong layout for B, too more 4 bytes
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct B {
pub _base: A,
pub Y: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_B() {
assert_eq!(
::std::mem::size_of::<B>(),
16usize,
concat!("Size of: ", stringify!(B))
);
C++ demonstration:
https://gist.github.com/not-fl3/1e2d478b6c74230c313fb4e1716b937b
Size of class is different for composition and inheritance, also with different field's visibility.
Expected Results
Probably, correct represntation of c++ memory layout will be with embedded public fields from base class to derived class. Not actually sure about this.
Metadata
Metadata
Assignees
Labels
No labels