1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#[repr(C, packed)] #[derive(Copy, Clone, Debug, PartialEq)] struct Foo { a: i8, b: i16, c: i8, } #[link(name = "test", kind = "static")] extern "C" { fn foo(f: Foo) -> Foo; } fn main() { unsafe { let a = Foo { a: 1, b: 2, c: 3 }; let b = foo(a); assert_eq!(a, b); } }