1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#[repr(C)]
#[derive(Debug, Default)]
pub struct Foo {
pub bar: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_Foo() {
assert_eq!(
::std::mem::size_of::<Foo>(),
4usize,
concat!("Size of: ", stringify!(Foo))
);
assert_eq!(
::std::mem::align_of::<Foo>(),
4usize,
concat!("Alignment of ", stringify!(Foo))
);
fn test_field_bar() {
assert_eq!(
unsafe {
let uninit = ::std::mem::MaybeUninit::<Foo>::uninit();
let ptr = uninit.as_ptr();
::std::ptr::addr_of!((*ptr).bar) as usize - ptr as usize
},
0usize,
concat!(
"Offset of field: ",
stringify!(Foo),
"::",
stringify!(bar)
)
);
}
test_field_bar();
}
|