I wrote DLL to handle my VSCAN communication in golang. I'm facing a really hard problem now. Is there any way to signal state from cgo to c/cpp program?
I'm using a large CPP project, inside it calls external golang DLL (compiled with GCC). Program pass Handle to the event:
// this is a function from DLL (written in go). I want to pass the event handler there.
VSCAN_STATUS VSCAN_SetRcvEvent(VSCAN_HANDLE Handle, HANDLE Event);
// Calling it from c:
sg_hEventRecv = CreateEvent(nullptr, FALSE, FALSE, nullptr);
VSCAN_SetRcvEvent(1, sg_hEventRecv)
I store the passed HANDLER in go dll:
package test
import "C"
var event C.HANDLE
func signalState(){
C.SetEvent(event)
}
//export VSCAN_SetRcvEvent
func VSCAN_SetRcvEvent(Handle VSCAN_HANDLE, Event C.HANDLE) int {
event = Event
return 0
}
Every time I want to signal state from go, it returns error code 6 (invalid handler).