Add go-to-rust via cgo. Dynamic and static variants.
This commit is contained in:
15
go-to-rust-cgo-static/src/double.go
Normal file
15
go-to-rust-cgo-static/src/double.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package main
|
||||
|
||||
//#cgo LDFLAGS: -L${SRCDIR}/../target/debug -ldouble_input -ldl
|
||||
//#include <stdint.h>
|
||||
//extern int32_t double_input(int32_t input);
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
input := 2
|
||||
double := C.double_input(C.int32_t(input))
|
||||
fmt.Printf("%d * 2 = %d\n", input, double)
|
||||
}
|
||||
Reference in New Issue
Block a user