| #![allow( |
| dead_code, |
| non_snake_case, |
| non_camel_case_types, |
| non_upper_case_globals |
| )] |
| |
| #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] |
| #[repr(C)] |
| pub struct __BindgenComplex<T> { |
| pub re: T, |
| pub im: T, |
| } |
| #[repr(C)] |
| #[derive(Debug, Copy, Clone)] |
| pub struct foo { |
| pub bar: ::std::os::raw::c_float, |
| pub baz: ::std::os::raw::c_float, |
| pub bazz: ::std::os::raw::c_double, |
| pub bazzz: *mut u128, |
| pub complexFloat: __BindgenComplex<::std::os::raw::c_float>, |
| pub complexDouble: __BindgenComplex<::std::os::raw::c_double>, |
| } |
| #[test] |
| fn bindgen_test_layout_foo() { |
| assert_eq!( |
| ::std::mem::size_of::<foo>(), |
| 48usize, |
| concat!("Size of: ", stringify!(foo)) |
| ); |
| assert_eq!( |
| ::std::mem::align_of::<foo>(), |
| 8usize, |
| concat!("Alignment of ", stringify!(foo)) |
| ); |
| assert_eq!( |
| { |
| let struct_instance = unsafe { std::mem::zeroed::<foo>() }; |
| let struct_ptr = &struct_instance as *const foo; |
| let field_ptr = std::ptr::addr_of!(struct_instance.bar); |
| let struct_address = struct_ptr as usize; |
| let field_address = field_ptr as usize; |
| std::mem::forget(struct_instance); |
| field_address.checked_sub(struct_address).unwrap() |
| }, |
| 0usize, |
| concat!("Offset of field: ", stringify!(foo), "::", stringify!(bar)) |
| ); |
| assert_eq!( |
| { |
| let struct_instance = unsafe { std::mem::zeroed::<foo>() }; |
| let struct_ptr = &struct_instance as *const foo; |
| let field_ptr = std::ptr::addr_of!(struct_instance.baz); |
| let struct_address = struct_ptr as usize; |
| let field_address = field_ptr as usize; |
| std::mem::forget(struct_instance); |
| field_address.checked_sub(struct_address).unwrap() |
| }, |
| 4usize, |
| concat!("Offset of field: ", stringify!(foo), "::", stringify!(baz)) |
| ); |
| assert_eq!( |
| { |
| let struct_instance = unsafe { std::mem::zeroed::<foo>() }; |
| let struct_ptr = &struct_instance as *const foo; |
| let field_ptr = std::ptr::addr_of!(struct_instance.bazz); |
| let struct_address = struct_ptr as usize; |
| let field_address = field_ptr as usize; |
| std::mem::forget(struct_instance); |
| field_address.checked_sub(struct_address).unwrap() |
| }, |
| 8usize, |
| concat!("Offset of field: ", stringify!(foo), "::", stringify!(bazz)) |
| ); |
| assert_eq!( |
| { |
| let struct_instance = unsafe { std::mem::zeroed::<foo>() }; |
| let struct_ptr = &struct_instance as *const foo; |
| let field_ptr = std::ptr::addr_of!(struct_instance.bazzz); |
| let struct_address = struct_ptr as usize; |
| let field_address = field_ptr as usize; |
| std::mem::forget(struct_instance); |
| field_address.checked_sub(struct_address).unwrap() |
| }, |
| 16usize, |
| concat!( |
| "Offset of field: ", |
| stringify!(foo), |
| "::", |
| stringify!(bazzz) |
| ) |
| ); |
| assert_eq!( |
| { |
| let struct_instance = unsafe { std::mem::zeroed::<foo>() }; |
| let struct_ptr = &struct_instance as *const foo; |
| let field_ptr = std::ptr::addr_of!(struct_instance.complexFloat); |
| let struct_address = struct_ptr as usize; |
| let field_address = field_ptr as usize; |
| std::mem::forget(struct_instance); |
| field_address.checked_sub(struct_address).unwrap() |
| }, |
| 24usize, |
| concat!( |
| "Offset of field: ", |
| stringify!(foo), |
| "::", |
| stringify!(complexFloat) |
| ) |
| ); |
| assert_eq!( |
| { |
| let struct_instance = unsafe { std::mem::zeroed::<foo>() }; |
| let struct_ptr = &struct_instance as *const foo; |
| let field_ptr = std::ptr::addr_of!(struct_instance.complexDouble); |
| let struct_address = struct_ptr as usize; |
| let field_address = field_ptr as usize; |
| std::mem::forget(struct_instance); |
| field_address.checked_sub(struct_address).unwrap() |
| }, |
| 32usize, |
| concat!( |
| "Offset of field: ", |
| stringify!(foo), |
| "::", |
| stringify!(complexDouble) |
| ) |
| ); |
| } |
| impl Default for foo { |
| fn default() -> Self { |
| let mut s = ::std::mem::MaybeUninit::<Self>::uninit(); |
| unsafe { |
| ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1); |
| s.assume_init() |
| } |
| } |
| } |