Callbacks in D as void functions

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Nov 13 10:28:39 PST 2014


On 11/13/14 10:58 AM, Wsdes wrote:

> First of all, the link to the wiki that has an example of callbacks in C
> and D:
> http://dlang.org/interfaceToC.html
>
> Secondly, I tried your code and that was exactly what I was thinking and
> what I tried before. Then I thought I'd turn to the wiki example, so
> that's where the int function came from. In the meantime I changed that
> to return void so I gave you my old code :(

The int example in the above "wiki" page (not technically a wiki, but 
that's OK) is because the function type in C is ALSO taking ints :)

Not all callback functions are the same. Your callback type in D should 
be the same as the C definition, but with extern(C).

Can you tell us the exact prototype of the function you are trying to 
assign, whether it is a member of a struct, class, or is an inner 
function, and the exact prototype you declared the Callback type to be? 
I don't need to see any code of the function.

-Steve


More information about the Digitalmars-d-learn mailing list