July 13, 2012
Am I correct in my understanding that we still don't have a reliable tool to translate a D source to C or C++? Can LDC/GDC do anything like that? (Doesn't LLVM have a C-outputting backend?)

July 13, 2012
On Jul 13, 2012 3:45 PM, "Nick Sabalausky" < SeeWebsiteToContactMe@semitwist.com> wrote:
>
> Am I correct in my understanding that we still don't have a reliable tool to translate a D source to C or C++? Can LDC/GDC do anything like that? (Doesn't LLVM have a C-outputting backend?)
>

Yes LLVM does.  I think GCC can do something like that too.  AFAIK this is the only way to do it.


July 13, 2012
On Fri, 13 Jul 2012 15:46:35 -0400
Kevin Cox <kevincox.ca@gmail.com> wrote:

> On Jul 13, 2012 3:45 PM, "Nick Sabalausky" < SeeWebsiteToContactMe@semitwist.com> wrote:
> >
> > Am I correct in my understanding that we still don't have a reliable tool to translate a D source to C or C++? Can LDC/GDC do anything like that? (Doesn't LLVM have a C-outputting backend?)
> >
> 
> Yes LLVM does.  I think GCC can do something like that too.  AFAIK this is the only way to do it.
> 

Oh cool. Anyone know anything about the state of it? Ie, this is the use-case I had in mind:

Currently using Marmalade (a C++-based system, uses basic classes/inheritance, but nothing too fancy) on Windows to develop iOS/Android stuff. Everything needs to be C/C++ (Marm's build system is unfortunately closed-source and tied to a specific set of C/C++ compilers).

Ideally, it'd be fantastic if I could write my derived classes and
such in D and just machine translate to C++ as a pre-build step.
Although I suspect that's hoping for too much. So even just implementing
certain non-class functions in D, translated to plain C, could be
helpful.

Any idea if it's up to this yet, or if not, what shortcomings there would be? Or staring points? (I haven't even used LDC or LLVM yet.) I'm sure anything using GC would be out of the question, of course.

(Apologies, it's occurring to me know I probably should have put this
whole thread in D.learn...)

July 13, 2012
On 13-07-2012 21:46, Kevin Cox wrote:
>
> On Jul 13, 2012 3:45 PM, "Nick Sabalausky"
> <SeeWebsiteToContactMe@semitwist.com
> <mailto:SeeWebsiteToContactMe@semitwist.com>> wrote:
>  >
>  > Am I correct in my understanding that we still don't have a reliable
>  > tool to translate a D source to C or C++? Can LDC/GDC do anything like
>  > that? (Doesn't LLVM have a C-outputting backend?)
>  >
>
> Yes LLVM does.  I think GCC can do something like that too.  AFAIK this
> is the only way to do it.
>

LLVM's C back end is deprecated since nobody used/maintained it.

Anyway, translating a D AST to C should be relatively trivial. Maybe you can base it on this: https://github.com/adamdruppe/dmd/tree/dtojs

-- 
Alex Rønne Petersen
alex@lycus.org
http://lycus.org
July 14, 2012
"Alex Rønne Petersen" <alex@lycus.org> wrote in message news:jtq05i$26hh$1@digitalmars.com...
> On 13-07-2012 21:46, Kevin Cox wrote:
>>
>
> Anyway, translating a D AST to C should be relatively trivial. Maybe you can base it on this: https://github.com/adamdruppe/dmd/tree/dtojs
>

Or base it off the c-generating fork that that's based on. https://github.com/yebblies/dmd/tree/microd

No classes though (or much at all really)


Top | Discussion index | About this forum | D home