Created
November 13, 2020 18:18
-
-
Save robbertvanginkel/05445fb48537f3b3b1ad8c51630685c4 to your computer and use it in GitHub Desktop.
Taken from https://golang.org/cmd/cgo/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
// typedef int (*intFunc) (); | |
// | |
// int | |
// bridge_int_func(intFunc f) | |
// { | |
// return f(); | |
// } | |
// | |
// int fortytwo() | |
// { | |
// return 42; | |
// } | |
import "C" | |
import "fmt" | |
func main() { | |
f := C.intFunc(C.fortytwo) | |
fmt.Println(int(C.bridge_int_func(f))) | |
// Output: 42 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment