digitalmars.D.learn - how do I pass this callback?
How do I define the callback so that it can be used in RegisterWaitForSingleObject()? I've tried pass as argument: myFunc &myFunc myFunc.ptr none worked. Here's my code:extern (C) void OnExited(void* context, BOOLEAN isTimeOut); extern(Windows): BOOL RegisterWaitForSingleObject( PHANDLE phNewWaitObject, HANDLE hObject, WAITORTIMERCALLBACK Callback, PVOID Context, ULONG dwMilliseconds, ULONG dwFlags );Function call:RegisterWaitForSingleObject(&hWait, hProcess, &OnExited, NULL, INFINITE, WT_EXECUTEONLYONCE);Error:function a.RegisterWaitForSingleObject(void** phNewWaitObject, void* hObject, extern (Windows) void function(void*, bool) Callback, void* Context, uint dwMilliseconds, uint dwFlags) is not callable using argument types (void**, void*, extern (C) void function(void* context, bool isTimeOut), typeof(null), uint, uint) a.d(38): cannot pass argument & OnExited of type extern (C) void function(void* context, bool isTimeOut) to parameter extern (Windows) void function(void*, bool) Callback
Mar 08 2018
On Thursday, 8 March 2018 at 17:06:05 UTC, Marc wrote:How do I define the callback so that it can be used in RegisterWaitForSingleObject()? I've tried pass as argument: myFunc &myFunc myFunc.ptr none worked. Here's my code:Solved! I shall rather use extern (Windows) not extern(C):[...]Function call:[...]Error:[...]extern (Windows) void OnExited(void* context, BOOLEAN isTimeOut);
Mar 08 2018