3 ms·
D can compile and link C programs with: dmd hello.c C and D code can be mixed with: dmd mars.d pluto.c C code can be imported by D code: import
by WalterBright 4y ago
D can compile and link C programs with:
dmd hello.c
C and D code can be mixed with:
dmd mars.d pluto.c
C code can be imported by D code:
import stdio; // looks for stdio.d, stdio.h, stdio.c in that order
void main() { printf("using C printf from D!"); }
It keys off of the file extension.
Amusingly, C code can also import D code:
----- D file ----
int square(int x) { return x * x; }
---- C file ----
__import square;
int test() { return square(3); }
closing the circle, enabling D libraries to be written and accessed by C.