www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - d and c

Hello. Randomly bored tonight.

Motivated by this: 

I was trying to get c to call d. I can't remember; is it actually possible?

64 bit Fedora and gcc; here's what I have:

$ cat test.d
import std.c.stdio;

     __gshared int x;

     void incx(){
         printf("x is now %d\n", x);

$ cat test2.c
#include <stdio.h>
extern int x;
void incx(void);

void main(void){
     printf("x: %d\n", x);

$ dmd -c test # works
$ gcc -m32 -L/usr/lib/dmd-2.048/lib/ -ldruntime -lphobos2 test.o test2.c 
# dies

When I include druntime or phobos2, the linker complains that the symbol 
`main' is defined multiple times. When I don't include either, it 
complains that the symbol `_Dmodule_ref' is undefined.

Aug 31 2010