Article: D Exceptions and C Callbacks

Johannes Pfau nospam at example.com
Wed Aug 7 00:10:20 PDT 2013


Am Wed, 07 Aug 2013 03:33:28 +0200
schrieb "Mike Parker" <aldacron at 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.


More information about the Digitalmars-d-announce mailing list