Add rust to go dynamic library example.

This commit is contained in:
Andrey Voronkov
2019-08-16 22:06:19 +02:00
parent 12f8d239f8
commit f09149f4f7
4 changed files with 45 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
package main
import "C"
//export DoubleInput
func DoubleInput(input int32) int32 {
return input * 2
}
func main() {}

View File

@@ -0,0 +1,12 @@
extern crate libc;
#[link(name = "double_input")]
extern {
fn DoubleInput(input: libc::c_int) -> libc::c_int;
}
fn main() {
let input = 2;
let output = unsafe { DoubleInput(input) };
println!("{} * 2 = {}", input, output);
}