October 11, 2005 calling a D function from within C | ||||
---|---|---|---|---|
| ||||
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? |
October 11, 2005 Re: calling a D function from within C | ||||
---|---|---|---|---|
| ||||
Posted in reply to David Schere | "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. |
Copyright © 1999-2021 by the D Language Foundation