Calling a D function from C

2010-11-12 Thread Carlo
Sorry if I bother you again with this probably silly problem. Here is the point. I want to call the D function "fun" from a .c file: \\file libforc.d extern (C) int fun(int x,int y){ return x; } \\EOF \\file ctest.c #include int fun(int,int); int main(int argc, char* argv[]) { p

Re: Calling a D function from C

2010-11-12 Thread Michal Minich
V Fri, 12 Nov 2010 16:14:30 +0100, Carlo wrote: > Sorry if I bother you again with this probably silly problem. Here is > the point. I want to call the D function "fun" from a .c file: > > \\file libforc.d > extern (C) int fun(int x,int y){ > return x; > } > \\EOF > > \\file ctest.c > #

Re: Calling a D function from C

2010-11-12 Thread Carlo
On 12/11/2010 16:19, Michal Minich wrote: V Fri, 12 Nov 2010 16:14:30 +0100, Carlo wrote: Sorry if I bother you again with this probably silly problem. Here is the point. I want to call the D function "fun" from a .c file: \\file libforc.d extern (C) int fun(int x,int y){ return x; }

Re: Calling a D function from C

2010-11-13 Thread Michal Minich
On Sat, 13 Nov 2010 00:00:00 +0100, Carlo wrote: > On 12/11/2010 16:19, Michal Minich wrote: >> V Fri, 12 Nov 2010 16:14:30 +0100, Carlo wrote: >> >>> Sorry if I bother you again with this probably silly problem. Here is >>> the point. I want to call the D function "fun" from a .c file: >>> >>> \\

Re: Calling a D function from C

2010-11-13 Thread Michal Minich
On Sat, 13 Nov 2010 00:00:00 +0100, Carlo wrote: > On 12/11/2010 16:19, Michal Minich wrote: >> V Fri, 12 Nov 2010 16:14:30 +0100, Carlo wrote: >> >>> Sorry if I bother you again with this probably silly problem. Here is >>> the point. I want to call the D function "fun" from a .c file: >>> >>> \\

Re: Calling a D function from C

2010-11-13 Thread Simen kjaeraas
Michal Minich wrote: first: extern (C) means that the function 'fun' is not defined in D, but in C. Wrong. It means the function has C calling convention. If it has a body, it is defined in D, and can be called from C (and D). If not, it is defined elsewhere, and can be called from D. -- Sim

Re: Calling a D function from C

2010-11-13 Thread Michal Minich
On Sat, 13 Nov 2010 14:20:05 +0100, Simen kjaeraas wrote: > Michal Minich wrote: > >> first: extern (C) means that the function 'fun' is not defined in D, >> but in C. > > Wrong. It means the function has C calling convention. If it has a body, > it is defined in D, and can be called from C (an

Re: Calling a D function from C

2010-11-14 Thread Carlo
On 12/11/2010 16:19, Michal Minich wrote: V Fri, 12 Nov 2010 16:14:30 +0100, Carlo wrote: Sorry if I bother you again with this probably silly problem. Here is the point. I want to call the D function "fun" from a .c file: \\file libforc.d extern (C) int fun(int x,int y){ return x; }

Re: Calling a D function from C

2010-11-14 Thread Carlo
On 13/11/2010 14:20, Simen kjaeraas wrote: Michal Minich wrote: first: extern (C) means that the function 'fun' is not defined in D, but in C. Wrong. It means the function has C calling convention. If it has a body, it is defined in D, and can be called from C (and D). If not, it is defined