how to get .c equivalent of a .cpp

Maxim Kuvyrkov maxim@codesourcery.com
Wed Jul 13 08:45:00 GMT 2011


On Jul 13, 2011, at 12:00 PM, ranjith kumar wrote:

> Hi,
> 1) I read somewhere that .cpp code is converted into .c code by the
> compiler, and .c file is used to make the executable file.

This was the way first C++ compilers operated.  GCC compiles C++ code directly into assembly.

> 
> Is there any flag to get the .c equivalent of .cpp file??
> If no, how to get it?

Try searching for an old compiler that does this; beware, code may not be pretty or work reliably.  You can try LLVM, which, I think, compiles C++ into its internal representation, which you then can compile back to C.

> 
> 2)What are the all possible cases in which GCC creates the temporary objects?
> How to disable the compiler from producing temporary objects?

Try -pipe compiler option.

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics



More information about the Gcc-help mailing list