Am Wed, 07 Aug 2013 12:08:44 +0200
schrieb "Mike Parker" <aldac...@gmail.com>:

> On Wednesday, 7 August 2013 at 07:10:21 UTC, Johannes Pfau wrote:
> > Am Wed, 07 Aug 2013 03:33:28 +0200
> > schrieb "Mike Parker" <aldac...@gmail.com>:
> >
> >> 
> >> > Maybe modifying glfwSetWindowCloseCallback and similar 
> >> > functions to only accept nothrow functions is a good idea?
> >> 
> >> I'm not sure what you mean. That's a C function, which means 
> >> it doesn't have any concept of D's nothrow. And, actually, the 
> >> callbacks should be declared as nothrow anyway. Like:
> >
> > He meant declaring glfwSetWindowCloseCallback like this:
> > alias extern(C) nothrow void function() callback;
> > extern(C) void glfwSetWindowCloseCallback(callback cb);
> >
> > http://dpaste.dzfl.pl/0f23146f
> > There's no difference in the generated code, but this way the 
> > compiler
> > will complain if you pass a non-nothrow function to
> > glfwSetWindowCloseCallback.
> 
> Yeah, I see. I misunderstood. I agree that the callbacks should 
> be declared as nothrow. In Derelict, all the C function pointers 
> are declared as such. Apparently, I overlooked adding it to the 
> callbacks.

I recently proposed using nothrow in GtkD as well. This
article was kind of a coincidence now. Yes, it is a real issue
with binding to C code unfortunately. Especially on amd64 with
GCC compiled stuff since it omits the stack frame that DMD
requires to unwind the stack resulting in immediate crashes
(druntime HLTs the execution) as soon as you throw an
exception from a callback.

-- 
Marco

Reply via email to