How to make D libraries callable from C?

Gregor Richards Richards at codu.org
Mon Dec 18 08:11:20 PST 2006


%u wrote:
> Hello,
> I am a D newbie and my company makes heavy use of C. I would like to
> demonstrate that the D language can be beneficial much more than Java.
> My question is: is it possible to make a library, that is callable
> from C? I guess i would have to write the corresponding .h file for
> inclusion, with possibly a C-wrapper around the D classes.
> Thank you for helping.
> 
> Alain

All you need is to use extern (C) on those functions you want to be 
callable from C.

D:

extern (C) void doStuff(int withThis) { ... }


C header:
void doStuff(int);

  - Gregor Richards



More information about the Digitalmars-d mailing list