digitalmars.D - calling a D function from within C
- David Schere (4/4) Oct 11 2005 First of all thank you for the D programming language. I am still scopin...
- Jarrett Billingsley (11/17) Oct 11 2005 In D, make a function and compile it with C linkage, like so:
First of all thank you for the D programming language. I am still scoping it out but it looks quite impressive. I was looking for a way to call a D function from within C as part of a callback routine. Any suggestions on how to do this?
Oct 11 2005
"David Schere" <David_member pathlink.com> wrote in message news:dih236$22er$1 digitaldaemon.com...First of all thank you for the D programming language. I am still scoping it out but it looks quite impressive. I was looking for a way to call a D function from within C as part of a callback routine. Any suggestions on how to do this?In D, make a function and compile it with C linkage, like so: extern(C) void fork() { } Then give the address of that function to your C function.. someCFunctionThatTakesAFunctionPointer(&fork); And it should work. If you're looking to make a DLL or library in D that can be used in C, that's another story.
Oct 11 2005