Calling D from C

There's very little new to bring to the table when discussing how to call D from C. On the D side, any functions and global variables that should be available for C should be declared extern(C). You could use extern(Windows) or extern(System) for special cases, but generally extern(C)is what you want. On the C side, all that needs to be done is to create a standard C header with the appropriate type declarations and function prototypes, or global variables. As long as the linkage attributes are correct, any C code linked with the D code will think it's talking to C.

At the time of writing, shared library support for DMD is not complete. It isn't implemented at all on OS X. Now and again, someone asks for help in the forums when ...

Get Learning D now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.