The D and C Series

This is an ongoing series of posts about interfacing D with C, interfacing C with D, and using D’s -betterC mode to port C code to D. While D can easily interoperate with C out of the box, there are some dark corners where things can jump out and bite. This series aims to shed some light in those corners to help D coders avoid injury.

Prerequisite

DMD, Windows, and C — the posts in this series encourage readers to compile and run the example code locally. Setting up an environment to compile C code is straightforward on Mac, Linux, and BSD systems. Existing documentation can be used to install the C compiler toolchain there is no special configuration required for DMD. The situation is different on Windows, where DMD may need configuration. Windows users should read this post first if they are unfamiliar with configuring DMD to use the Microsoft C and C++ build tools.

Interfacing D with C

Getting Started — this post shows how to compile a C source file to an object file, then link that object file with a D program using DMD. Along the way, it shows how to bind D functions to C functions and introduces the first of the dark corners the series will explore.