I have created a dll in vs2019 c++. It has some exported function, and it has to call back a function in a specific event. It is imported in a Delphi project (it is written by another person).
Evertyhing works well in x86, but it gives an Access violation error on the callback in x64 (OnEvent()).
I tried to set the calling convention, but it isn't worked.
What should i do?
typedef void (__cdecl *EventCallback)();
extern EventCallback OnEvent = NULL;
extern "C" {
__declspec(dllexport) void __cdecl SetEventCallback(EventCallback func);
__declspec(dllexport) void __cdecl FireEvent();
}
extern void __cdecl SetEventCallback(EventCallback func) {
OnEvent = func;
}
extern void __cdecl FireEvent() {
if (OnEvent)
OnEvent();
}