Exemple #1
0
func testFpVar(t *testing.T) {
	const expected = 42
	f := C.intFunc(C.fortytwo)
	res1 := C.bridge_int_func(f)
	if r1 := int(res1); r1 != expected {
		t.Errorf("got %d, want %d", r1, expected)
	}
	res2 := callCBridge(f)
	if r2 := int(res2); r2 != expected {
		t.Errorf("got %d, want %d", r2, expected)
	}
	r3 := callBridge(f)
	if r3 != expected {
		t.Errorf("got %d, want %d", r3, expected)
	}
}
Exemple #2
0
func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())
	f := C.intFunc(C.fortytwo)
	fmt.Println(int(C.bridge_int_func(f)))
	// Output: 42
}
Exemple #3
0
func main() {
	f := C.intFunc(C.fortytwo)
	fmt.Println(int(C.bridge_int_func(f)))
	// Output: 42
}
Exemple #4
0
//export Bridge
// This Go function is called from C
func Bridge(param string, callback unsafe.Pointer) string {
	uuid := uuid.NewV4()
	cs := C.CString("Hello World!")
	return fmt.Sprintf("[%s] %s = %d (%d)", uuid.String(), param, C.bridge_int_func(C.intFunc(callback)), C.CBridge(cs))
}