Problems with function as parameter
Mike Parker
aldacron at gmail.com
Fri Sep 22 02:18:34 UTC 2017
On Thursday, 21 September 2017 at 22:05:22 UTC, Matt Jones wrote:
> On Thursday, 21 September 2017 at 20:21:58 UTC, Josh wrote:
>> I'm trying to write a callback function for SDL_mixer through
>> Derelict, but this is the first time I've tried to use a
>> function as a parameter, and so I think I'm just making a
>> minor mistake somewhere.
>>
>> [...]
>
> Make it a C function, not a D function:
>
> extern (C) void channelDone(int channel)
> {
> unmuteMusic();
> }
>
> and use & to reference the function instead of calling it:
>
> Mix_ChannelFinished(&channelDone);
It should be extern(C) and, ideally, nothrow. The binding should
be enforcing nothrow, but currently doesn't. I'll change that now.
More information about the Digitalmars-d-learn
mailing list