2014-08-01 23:25:41 -05:00
|
|
|
extern crate testcrate;
|
|
|
|
|
2020-09-01 16:12:52 -05:00
|
|
|
extern "C" fn bar<T>(ts: testcrate::TestStruct<T>) -> T {
|
|
|
|
ts.y
|
|
|
|
}
|
2014-08-01 23:25:41 -05:00
|
|
|
|
2016-12-05 18:31:05 -06:00
|
|
|
#[link(name = "test", kind = "static")]
|
2020-09-01 16:12:52 -05:00
|
|
|
extern "C" {
|
2014-08-01 23:25:41 -05:00
|
|
|
fn call(c: extern "C" fn(testcrate::TestStruct<i32>) -> i32) -> i32;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Let's test calling it cross crate
|
2020-09-01 16:12:52 -05:00
|
|
|
let back = unsafe { testcrate::call(testcrate::foo::<i32>) };
|
2014-08-01 23:25:41 -05:00
|
|
|
assert_eq!(3, back);
|
|
|
|
|
|
|
|
// And just within this crate
|
2020-09-01 16:12:52 -05:00
|
|
|
let back = unsafe { call(bar::<i32>) };
|
2014-08-01 23:25:41 -05:00
|
|
|
assert_eq!(3, back);
|
|
|
|
}
|