D to C compiler?

Nick Sabalausky a at a.a
Sun Jan 25 10:43:02 PST 2009


"Nicolay Korslund" <korslund at gmail.com> wrote in message 
news:glhuiu$11ck$1 at digitalmars.com...
>I remember reading something about a D to C compiler on this group a few 
>years ago. (I'm not really a regular here anymore, so there might have been 
>more recent mentions that I've missed.) Does anyone know if there's any 
>such project still around that's alive or could be revived? Or if there's 
>any other viable solutions for converting D to C (or C++)?
>
> The reason I would want to do this is to port D code to currently 
> non-supported platforms. This is especially important for game projects 
> (like my own monsterscript project) - most game console SDKs take C/C++ 
> and nothing else. The C/C++ output wouldn't have to be nice or even human 
> readable - just compilable. It would only be used as a middle step in the 
> compilation process for these platforms.
>
> Any ideas or suggestions?
>
> Nico

I don't think there's anything like that in a fully-usable form just yet, 
but there are at least a few leads:

- Like Denis said, I've heard LLVM is supposed to have a plain-C backend, 
but I don't know how far along that is or if it's working with LDC (and from 
what I hear, even LDC itself isn't quite production-ready just yet, but it 
is movng along quickly).

- It might be possible to create something with ANTLR to do this, but you'd 
have to define a full D grammar in ANTLR along with instructions on how to 
convert it to C. A lot of work, but might be easier than a full from-scratch 
D-to-C converter.

- Also, I'm in the early stages of a pet project that, if successful, may 
eventually be able to do that. But it's nowhere near such a level yet.

But regardless, the ability to convert D to plain C is something that IMO 
really does need to happen at some point. 





More information about the Digitalmars-d mailing list