March 08, 2018 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 |
March 08, 2018 Re: how do I pass this callback? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Marc | 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: > >>[...] > > Function call: > >> [...] > > Error: > >> [...] Solved! I shall rather use extern (Windows) not extern(C): >extern (Windows) void OnExited(void* context, BOOLEAN isTimeOut); |
Copyright © 1999-2021 by the D Language Foundation