I got a callback from a dll, the function ptr type defined:
typedef int32_t (WINAPI *fn) ();
if I use cgo, we can do like this:
/*
#include <windows.h>
#include <stdint.h>
typedef int32_t (WINAPI *fn) ();
int32_t call_callback(fn f){
f();
}
*/
import "C"
import (
"unsafe"
)
func main() {
var callBackPtr uintptr // from dll function
C.call_callback((C.fn)(unsafe.Pointer(callBackPtr)))
}
BUT! I don't want to use cgo. How can I achieve in pure go?