AFAIK it's that code which compiles in both c and d should have the same behaviour; not that c code should necessarily compile in d. Examples of c that don't work in d are trivial.
> there are tools to convert C to D (As used in the dmd compiler backend (which dates back to the 80s I believe, but is now in a tasty form of spaghetti D)
Dmd's backend was ported by hand. What tools are those? I know there are tools to convert header files, but I don't know of any that actually convert code.
> Dmd's backend was ported by hand
I stand corrected then. Visual D has one cpp2d built in, which I assumed was used
Not quite, the c++ source was massaged to be free of weird corner cases of the grammar and preprocessor (e.g. enforcing no spaces between '#' and the preprocessor keyword) and then a tool called magicport was used to convert the frontend in one shot. The backend was mostly converted by "hand" (i.e. grep after some more massaging).
There are several tools to translate headers though dstep[1] and dpp[2] come to mind
[1]: https://github.com/jacob-carlborg/dstep [2]: https://github.com/atilaneves/dpp
Most of the conversion was "replace -> with ." and then fixing whatever the compiler complained about.
You'd be right!
> but is now in a tasty form of spaghetti D)
Haha. It's still as awful as the C code it was manually converted to D from. I've been slowly improving it bit by bit.
Could a step forward be to start afresh and then call into the old backend stages but ultimately rewrite them in more bearable code where possible? Might be a compile time trade-off there, to an extent.