rust/tests/ui/abi/extern/extern-pass-TwoU8s.rs

25 lines
500 B
Rust
Raw Normal View History

//@ run-pass
#![allow(improper_ctypes)]
// Test a foreign function that accepts and returns a struct
// by value.
2015-03-30 13:38:27 +00:00
#[derive(Copy, Clone, PartialEq, Debug)]
pub struct TwoU8s {
2020-09-01 21:12:52 +00:00
one: u8,
two: u8,
}
2016-11-24 00:09:51 +00:00
#[link(name = "rust_test_helpers", kind = "static")]
2020-09-01 21:12:52 +00:00
extern "C" {
pub fn rust_dbg_extern_identity_TwoU8s(v: TwoU8s) -> TwoU8s;
}
pub fn main() {
unsafe {
2020-09-01 21:12:52 +00:00
let x = TwoU8s { one: 22, two: 23 };
let y = rust_dbg_extern_identity_TwoU8s(x);
assert_eq!(x, y);
}
}