D to C compiler?
Nicolay Korslund
korslund at gmail.com
Fri Feb 6 06:20:40 PST 2009
Jarrett Billingsley Wrote:
> On Sun, Jan 25, 2009 at 2:11 PM, dsimcha <dsimcha at yahoo.com> wrote:
> > == Quote from Nick Sabalausky (a at a.a)'s article
> >> - 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).
> >
> > This is true. I've played around w/ this C back end w/ some toy programs and and
> > it works reasonably well, but I forgot about it. At any rate, could this be used
> > as a temporary kludge to get LDC "working" on unsupported platforms like Windows
> > until it works natively? Basically, LDC for Windows and other unsupported
> > platforms would compile the D code to C, and then compile the C code w/ the native
> > C compiler for the platform.
>
> The problem with LDC on Windows is not that LLVM doesn't have a
> backend for Windows; it does. It's just that LLVM doesn't yet support
> Windows exception handling. Using the C backend wouldn't help there.
Reviving a slightly dated thread here:
The exception problem and C could be sidestepped altogether by compiling to C++ instead of pure C. All the major console SDKs at least will compile C++. This doesn't mean we would need to use any more C++ features like classes or templates, the result could be pretty much "C with exceptions". An added benefit would be automatic eh compatibility with existing C++ code, on all platforms.
As a side note, compiling D->C++ could probably be done at a higher level than using C-as-assembler-output, which I suspect is what LLVM will end up doing. This isn't a high priority though.
Nico
More information about the Digitalmars-d
mailing list