Unable to Call unsafe.Pointer(Pointed to C Function) as Function
问题 I'm trying to call C function with same signature they take 2 int arguments. and this error cannot call non-function f (type unsafe.Pointer) appear during compile. package main /* int add(int a, int b) { return a+b; } int sub(int a, int b) { return a-b; } */ import "C" import ( "fmt" "unsafe" ) func main() { a := C.int(1) b := C.int(2) fx := make([]unsafe.Pointer, 2) fx[0] = C.add fx[1] = C.sub for _, f := range fx { fmt.Printf("Result: %d\n", f(a, b)) } } Now I'm working around with wrap C