Interfacing C with D...How to?

Dié d.cavadini at freesurf.ch
Mon Apr 23 09:24:38 PDT 2007


Hello!

The super guide "D Specification" is not so super sometimes...

So, someone has worked with C code in D? 

i haved coded a little example to try this feature.


Simple c file with one fuction:
// test.c
#include "htest.h"

void printFromC(){
  printf("Hello World (printed from C)");
}

his header file:
// htest.h
void printFromC();

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);

d main file:
// main.d
import htest;
int main(char[][] args){
		printFromC();
}

I have no idea if i've coded correctly, and how copile/link...?????

Someone can help me?

Tks! :-P

Dié






More information about the Digitalmars-d mailing list