D and C APIs

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 10:59:01 PST 2016


Many times I've considered simply incorporating a C compiler into the D 
compiler, and then:

   import "stdio.h";

The perennial problem, however, is the C preprocessor and all the bizarre things 
people do with it in even the most mundane header files. The problem is NOT, 
however, implementing the preprocessor, as that's already done. The problem is C 
#include files do not exist in a vacuum; they derive their meaning based on the 
compiler used, the predefined macros, and the host file they were #include'd in.

Well, and the inevitable C language extensions, different for every compiler, 
and the developers determined to use every last one of them :-(

Then there's what type does 'char' map to?

When the D compiler guesses wrong about all these issues, there's no way to see 
or correct what it did, and so we wind up with endless "bugs" and support issues.

It's better to have a separate translator, and the user can tweak the results of it.


More information about the Digitalmars-d mailing list