There are two ongoing series of posts about using D with C: the D and C series about using D and C in the same program in general, and the DasBetterC series about using D’s
-betterC mode to convert C programs to D as painlessly as possible.
The D and C Series
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.
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.
Arrays Part One — this post examines the differences between array declarations in D and C and how those differences may bring about some unwelcome surprises.
Arrays Part Two — this post looks at how to declare and call in C functions in D that take array parameters.
Strings Part One — this post explores the implementation of D strings and C strings, how to handle NUL termination when passing D strings to C, and how to avoid it as a consequence of a special D feature.
The D as BetterC (DasBetterC) Series
In this series, D’s creator and BDFL Walter Bright explains D’s
-betterC mode and shows how to use it to conveniently port existing C programs to D, step-by-step, with the aim of improving memory safety and reducing bug counts.
D as a Better C — an introduction to
-betterC, the rationale behind it, and how it differs from standard D.
Vanquish Forever These Bugs That Blasted Your Kingdom — an in-depth example on how
-betterC can be used a common bug in C.
DasBetterC: Converting make.c to D — Walter shows step-by-step how he converted an implementation of the make program from C to D using