Call a function with a function pointer
Benjamin Thaut
code at benjamin-thaut.de
Thu Oct 10 07:26:41 PDT 2013
Am 10.10.2013 16:13, schrieb Namespace:
> I have this function:
> ----
> void foo(T)(void function(T*) test) { }
> ----
>
> And want to call it with a C function:
> ----
> foo!(SDL_Surface)(SDL_FreeSurface);
> ----
>
> but I get:
> Fehler 1 Error: foo (void function(SDL_Surface*) test) is not
> callable using argument types (extern (C) void function(SDL_Surface*)
> nothrow)
>
> What would be the smartest solution?
If you can change the signature of foo just add a extern(c) to the
function pointer declaration.
Otherwise just wrap the SDL_FreeSurface call into a delegate on the
caller side.
--
Kind Regards
Benjamin Thaut
More information about the Digitalmars-d-learn
mailing list