]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | extern crate testcrate; |
2 | ||
5869c6ff XL |
3 | extern "C" fn bar<T>(ts: testcrate::TestStruct<T>) -> T { |
4 | ts.y | |
5 | } | |
1a4d82fc | 6 | |
476ff2be | 7 | #[link(name = "test", kind = "static")] |
5869c6ff | 8 | extern "C" { |
1a4d82fc JJ |
9 | fn call(c: extern "C" fn(testcrate::TestStruct<i32>) -> i32) -> i32; |
10 | } | |
11 | ||
12 | fn main() { | |
13 | // Let's test calling it cross crate | |
5869c6ff | 14 | let back = unsafe { testcrate::call(testcrate::foo::<i32>) }; |
1a4d82fc JJ |
15 | assert_eq!(3, back); |
16 | ||
17 | // And just within this crate | |
5869c6ff | 18 | let back = unsafe { call(bar::<i32>) }; |
1a4d82fc JJ |
19 | assert_eq!(3, back); |
20 | } |