digitalmars.com                        
Last update Sat Oct 7 16:49:30 2023

Using D as a Better C

June 21, 2017

written by Walter Bright

D as a “Better C” is based on the idea that a project written in C can contain files that are compiled with C or with D. D files can be incrementally and easily added to a C project. Translating existing C files to D can be straightforward.

More specifically, D as Better C (as opposed to being D) means:

  1. D supports C style programming.
  2. A D compiled module can be linked in to a C program without the rest of the program needing to adapt to it.
  3. The D runtime library will not be needed to be linked in.

To make this work, some behaviors of D will need to be adjusted, hence the addition of a `-betterC` compiler switch. Many features of D will not work as Better C, so a subset will be needed.

Effect of -betterC Switch

Not supported D features in Better C

D features that will work in Better C

References

Home | Runtime Library | IDDE Reference | STL | Search | Download | Forums