2 ms·
A member of our community accidentally discovered that the D compiler could translate C code to D code. D has a module system, where you import a module and it
by WalterBright 2y ago
A member of our community accidentally discovered that the D compiler could translate C code to D code.
D has a module system, where you import a module and it pulls the global declarations out of it. To speed up this process, there's a compiler switch to output just the global declarations to another file, a .di file, that functions much like a .h file in C.
Then there came along ImportC, where a C lexer/parser was welded onto the D compiler logic.
aaaand it wasn't long before the switch was thrown to generate a .di file, and voila, the C code got translated to D!
This resulted in making it dramatically easier to use existing C headers and source files with D.