|
| 1 | +extern "C" { |
| 2 | + pub static mut foo: ::std::option::Option< |
| 3 | + unsafe extern "C" fn( |
| 4 | + x: ::std::os::raw::c_int, |
| 5 | + y: ::std::os::raw::c_int, |
| 6 | + ) -> ::std::os::raw::c_int, |
| 7 | + >; |
| 8 | +} |
| 9 | +extern "C" { |
| 10 | + pub fn bar(a: *const ::std::os::raw::c_char) -> ::std::os::raw::c_int; |
| 11 | +} |
| 12 | +extern "C" { |
| 13 | + pub fn bar2(b: *const ::std::os::raw::c_char) -> f32; |
| 14 | +} |
| 15 | +pub type Char = ::std::os::raw::c_char; |
| 16 | +pub type SChar = ::std::os::raw::c_schar; |
| 17 | +pub type UChar = ::std::os::raw::c_uchar; |
| 18 | +#[repr(C)] |
| 19 | +#[derive(Debug, Copy, Clone)] |
| 20 | +pub struct Test { |
| 21 | + pub ch: ::std::os::raw::c_char, |
| 22 | + pub u: ::std::os::raw::c_uchar, |
| 23 | + pub d: ::std::os::raw::c_schar, |
| 24 | + pub cch: ::std::os::raw::c_char, |
| 25 | + pub cu: ::std::os::raw::c_uchar, |
| 26 | + pub cd: ::std::os::raw::c_schar, |
| 27 | + pub Cch: Char, |
| 28 | + pub Cu: UChar, |
| 29 | + pub Cd: SChar, |
| 30 | + pub Ccch: Char, |
| 31 | + pub Ccu: UChar, |
| 32 | + pub Ccd: SChar, |
| 33 | +} |
| 34 | +#[test] |
| 35 | +fn bindgen_test_layout_Test() { |
| 36 | + assert_eq!( |
| 37 | + ::std::mem::size_of::<Test>(), |
| 38 | + 12usize, |
| 39 | + concat!("Size of: ", stringify!(Test)) |
| 40 | + ); |
| 41 | + assert_eq!( |
| 42 | + ::std::mem::align_of::<Test>(), |
| 43 | + 1usize, |
| 44 | + concat!("Alignment of ", stringify!(Test)) |
| 45 | + ); |
| 46 | + assert_eq!( |
| 47 | + unsafe { &(*(::std::ptr::null::<Test>())).ch as *const _ as usize }, |
| 48 | + 0usize, |
| 49 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(ch)) |
| 50 | + ); |
| 51 | + assert_eq!( |
| 52 | + unsafe { &(*(::std::ptr::null::<Test>())).u as *const _ as usize }, |
| 53 | + 1usize, |
| 54 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(u)) |
| 55 | + ); |
| 56 | + assert_eq!( |
| 57 | + unsafe { &(*(::std::ptr::null::<Test>())).d as *const _ as usize }, |
| 58 | + 2usize, |
| 59 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(d)) |
| 60 | + ); |
| 61 | + assert_eq!( |
| 62 | + unsafe { &(*(::std::ptr::null::<Test>())).cch as *const _ as usize }, |
| 63 | + 3usize, |
| 64 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(cch)) |
| 65 | + ); |
| 66 | + assert_eq!( |
| 67 | + unsafe { &(*(::std::ptr::null::<Test>())).cu as *const _ as usize }, |
| 68 | + 4usize, |
| 69 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(cu)) |
| 70 | + ); |
| 71 | + assert_eq!( |
| 72 | + unsafe { &(*(::std::ptr::null::<Test>())).cd as *const _ as usize }, |
| 73 | + 5usize, |
| 74 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(cd)) |
| 75 | + ); |
| 76 | + assert_eq!( |
| 77 | + unsafe { &(*(::std::ptr::null::<Test>())).Cch as *const _ as usize }, |
| 78 | + 6usize, |
| 79 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(Cch)) |
| 80 | + ); |
| 81 | + assert_eq!( |
| 82 | + unsafe { &(*(::std::ptr::null::<Test>())).Cu as *const _ as usize }, |
| 83 | + 7usize, |
| 84 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(Cu)) |
| 85 | + ); |
| 86 | + assert_eq!( |
| 87 | + unsafe { &(*(::std::ptr::null::<Test>())).Cd as *const _ as usize }, |
| 88 | + 8usize, |
| 89 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(Cd)) |
| 90 | + ); |
| 91 | + assert_eq!( |
| 92 | + unsafe { &(*(::std::ptr::null::<Test>())).Ccch as *const _ as usize }, |
| 93 | + 9usize, |
| 94 | + concat!( |
| 95 | + "Offset of field: ", |
| 96 | + stringify!(Test), |
| 97 | + "::", |
| 98 | + stringify!(Ccch) |
| 99 | + ) |
| 100 | + ); |
| 101 | + assert_eq!( |
| 102 | + unsafe { &(*(::std::ptr::null::<Test>())).Ccu as *const _ as usize }, |
| 103 | + 10usize, |
| 104 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(Ccu)) |
| 105 | + ); |
| 106 | + assert_eq!( |
| 107 | + unsafe { &(*(::std::ptr::null::<Test>())).Ccd as *const _ as usize }, |
| 108 | + 11usize, |
| 109 | + concat!("Offset of field: ", stringify!(Test), "::", stringify!(Ccd)) |
| 110 | + ); |
| 111 | +} |
0 commit comments