Problems with function as parameter

Josh moonburntm at gmail.com
Fri Sep 22 02:32:56 UTC 2017


On Friday, 22 September 2017 at 02:18:34 UTC, Mike Parker wrote:
> 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.

Why should the binding force nothrow? I don't understand why you 
HAVE to not throw exceptions. Is it because of the C -> D aspect?


More information about the Digitalmars-d-learn mailing list