tags:

views:

308

answers:

3

While investigating the D language, I came across GDC, a D Compiler for GCC. I downloaded the version for MinGW from here:

http://sourceforge.net/projects/dgcc/files/

Documentation was almost nonexistent, but it did say that most of the command line switches were the same as for the GCC compiler. However, that doesn't help me much, since I don't usually build with GCC.

GDC is described as a "GCC front end". That makes me think that at some point it has to generate intermediate C++ or C that the GCC compiler can actually swallow. I believe that this is how GCC compiles Objective-C programs.

What I want to know is this: Is there a way to get GDC to emit the intermediate C/C++ code as files that I can then inspect and compile by hand with GCC/MinGW?

+5  A: 

Quick answer: no.

From what I know about GCC, it uses abstract syntax trees for the language-independent code representation that gets passed from the front-end to the back-end. Theoretically it might be possible to "decompile" that AST to C/C++ code, but AFAIK the GCC suite does not implement this.

CyberShadow
OK, but that's GCC. Presumably, GDC is just a separate front end that invokes GCC, passing its output in some recognizable form. (I'm speculating here.)
Buggieboy
+8  A: 

No.

Front-ends to GCC generate a language-independent representation that is then compiled directly to assembly. This is the case for the C, C++, Obj-C, D, Fortran, Java, Ada, and other front-ends. There is no intermediate C or C++ representation, nor can one be generated.

greyfade
+3  A: 

Basically, you need a gcc back-end that generates C/C++ as its target platform, rather than say, x86. This is completely possible but I'm not aware of an implementation that does this. By the way, if one exists, the output might not be very readable.

Mehrdad Afshari