Does D has any support for thunks?
Hiemlick Hiemlicker via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 1 18:42:27 PDT 2016
On Saturday, 25 June 2016 at 17:52:48 UTC, Andre Pany wrote:
> On Saturday, 25 June 2016 at 17:26:03 UTC, Andre Pany wrote:
>> On Saturday, 25 June 2016 at 16:05:30 UTC, Vladimir Panteleev
>> wrote:
>>> On Saturday, 25 June 2016 at 13:44:48 UTC, Andre Pany wrote:
>>>> Does D/Phobos has any support for thunks?
>>>
>>> Made this a while ago:
>>>
>>> http://stackoverflow.com/a/8656294/21501
>>
>> Thanks, I had a look. Unfortunately it doesn't compile for my
>> use case.
>> SetWindowsHookEx expects an "extern(windows)" and "nothrow"
>> function.
>> delegate2function does not accept a delegate with
>>
>> If it is possible to make this coding generic, it would fit
>> into
>> std.functional.
>>
>> Kind regards
>> André
>
> ... does not accept a delegate with extern(windows).
You can fix this by a cast:
alias callbackType = extern (Windows) uint function(void*);
CreateThread(cast(SECURITY_ATTRIBUTES*)null, stackSize,
cast(callbackType)delegate2function(c), cast(void*)¶m,
(suspended) ? CREATE_SUSPENDED : 0, &Id);
But there seems to be a problem as I can only get parameters to
pass correctly on dmd x64.
More information about the Digitalmars-d-learn
mailing list