1 #![allow(
2 dead_code,
3 non_snake_case,
4 non_camel_case_types,
5 non_upper_case_globals
6 )]
7
8 #[repr(C)]
9 #[repr(align(16))]
10 #[derive(Debug, Default, Copy, Clone)]
11 pub struct foo {
12 pub bar: u128,
13 }
14 #[test]
bindgen_test_layout_foonull15 fn bindgen_test_layout_foo() {
16 const UNINIT: ::std::mem::MaybeUninit<foo> =
17 ::std::mem::MaybeUninit::uninit();
18 let ptr = UNINIT.as_ptr();
19 assert_eq!(
20 ::std::mem::size_of::<foo>(),
21 16usize,
22 concat!("Size of: ", stringify!(foo))
23 );
24 assert_eq!(
25 ::std::mem::align_of::<foo>(),
26 16usize,
27 concat!("Alignment of ", stringify!(foo))
28 );
29 assert_eq!(
30 unsafe { ::std::ptr::addr_of!((*ptr).bar) as usize - ptr as usize },
31 0usize,
32 concat!("Offset of field: ", stringify!(foo), "::", stringify!(bar))
33 );
34 }
35