On Thursday, 13 November 2014 at 14:50:00 UTC, Wsdes wrote:
I am trying to write a wrapper for a C API in D. In C I have the
following definition of a callback type:
typedef void (*Callback)(void*);
I would translate this directly to D:
extern(C) alias Callback = void function(void*);
Here the MyDtaCB function has no prototype but is defined as
follows:
void MyDtaCB(void* pVoid){
// Do stuff
}
And don't forget extern(C) on this too:
extern(C) void MyDtaCB(void* pVoid) {
}
And assign it to the struct:
Events.OnData = &MyDtaCB;
Unless you have a link to the wiki that talks about ints, maybe
that says something different, but I like to keep my C and D code
that calls it looking pretty much the same when I can.