Re: C callbacks?
Stewart Gordon Wrote: > But do check whether you really want an alias (the D equivalent of > typedef in C) or a typedef (an actual new type in D). I believe it was a typedef in this case. There were other points where I used alias to get it all fixed up. Thankfully, my conversion seems to compile just fine, so now I'm writing the wrappers on that to make sure it all works correctly! Thank you for the heads up.
Re: C callbacks?
BCS Wrote: > in D the more normal way to write that would be: > > typedef bool function(bsp_t* node, void* userData) TCOD_bsp_callback_t; Ahh! Thanks a ton, that seems to work like I needed. > C code and delegates are incomparable but C and function pointers are not. I must have been misreading that bit then, thanks for clarifying. Listeners/Delegates have always confused me, I really need to do some tutorials and try to understand them better.
C callbacks?
I've hit another snag on my C library interfacing. The .h defines a function: //typedef bool (*TCOD_bsp_callback_t)(TCOD_bsp_t *node, void *userData); bool* bsp_callback_t(bsp_t* node, void* userData); //bsp_t is a struct defining the bsp tree Sidenote: Did I translate that right? Anyway, this function is later passed into various functions, like: bool bsp_traverse_pre_order(bsp_t *node, bsp_callback_t listener, void *userData); I've tried doing some reading on this board regarding c callbacks and delegates, but it feels a bit over my head. Can anyone assist me in figuring out how to D-ify this bit of code so I can interact with the C dll?