Error: WndProc - nothrow

Alex Rønne Petersen alex at lycus.org
Sun Sep 16 11:21:01 PDT 2012


On 16-09-2012 19:39, deed wrote:
> I get this error from a minimal windows example:
>
> import core.runtime;
> import std.c.windows.windows;
> import std.string;
>
> pragma(lib, "gdi32.lib");
>
> extern (Windows)
> {
> int WinMain( ... ) { ... }
> HRESULT appMain( ... ) {
>      ...
>      WNDCLASS wc;
>      ...
>      wc.lpfnWndProc = &wndProc;
>      ...
> }
> HRESULT wndProc( ... ) { ... }
> }
>
> Error: cannot implicitly convert expression (& wndProc) of type
> extern (Windows) int function(void* hwnd, uint message, uint wParam, int
> lParam)
> to
> extern (Windows) int function(void*, uint, uint, int) nothrow
> shell returned 1
>
> What does the nothrow stems from? Is this something new?

nothrow is a function attribute meaning "this function does not throw 
exceptions". Just mark your wndProc function as nothrow and it should go 
away.

http://dlang.org/function.html#nothrow-functions

-- 
Alex Rønne Petersen
alex at lycus.org
http://lycus.org


More information about the Digitalmars-d-learn mailing list