calling a D function from C and C++ code

Traveler Hauptman none at none.com
Mon Aug 27 21:02:51 PDT 2007


Bedros Hanounik wrote:
> 
> all the documentation...etc discusses how to bind an existing library to D code; which is the most common case, but how about building a brand new library written in D; can anyone write a C code (or C++) to interface this library in D.
> 
> Thanks,
> 
> -Bedros

<flamebait>
>From my occasional lurking it seems like calling native D libraries from
other languages is not a priority here. They just wave their hand at
extern(C) and go back to their meta-programming.
</flamebait>

Check out the ABI page to start with. http://digitalmars.com/d/abi.html
It gets more complete each year...  Last time I played with it using C I
was able to use a macro with the Dmangled function name and an extra
parameter for the object pointer in certain cases. A bug/feature of the
linux dmd compiler I think.

If you get inspired and crank out a preprocessor for language X that
lets you import .di files and prefix Dlib calls with "extern (D)" please
post it.

-traveler



More information about the Digitalmars-d mailing list