Interfacing C with D...How to?

torhu fake at address.dude
Mon Apr 23 17:31:38 PDT 2007


Dié wrote:
<snip>
> header file converted in d:
> /* Converted to D from htest.h by htod */
> // htest.d
> module htest;
> //#include <iostream>
> 
> //C     void printFromC();
> extern (C):
> void  printFromC(void);
extern (C):
void  printFromC();  // no void parameter

> I have no idea if i've coded correctly, and how copile/link...?????
> 
> Someone can help me?

If you're on windows, you have to compile the C file with dmc to get a 
file that you can link with dmd's output.  Like this:

dmc -c htest.c

And then compile the D file, and link them together to produce main.exe:

dmd main htest.o


Download (DMC) Digital Mars C compiler here:
http://www.digitalmars.com/download/dmcpp.html

On linux, you'd probably do the same thing, but use gcc instead of dmc.



More information about the Digitalmars-d mailing list