summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzy <[email protected]>2023-09-08 03:48:44 +0000
committerzy <[email protected]>2023-09-08 03:48:44 +0000
commit7865085c4477c0233cf07519af2b217365567a66 (patch)
tree9f0b916166b1fe19c1b5e5526bd5017d6683b8a0 /src
ffi hello worldHEADmasterhello-world
Diffstat (limited to 'src')
-rw-r--r--src/main.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..7f69b07
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,11 @@
+use std::os::raw::c_int;
+
+#[link(name = "sample")]
+extern "C" {
+ fn add(a: c_int, b: c_int) -> c_int;
+}
+
+fn main() {
+ let r = unsafe { add(2, 18) };
+ println!("{:?}", r);
+}