S
Sheky
Could anyone please answer if every C++ programs get converted to
equivalent C code during compilation ? Thank you.
equivalent C code during compilation ? Thank you.
Could anyone please answer if every C++ programs get converted to
equivalent C code during compilation ? Thank you.
I would like to say it was not a homework problem. I did not know thatYour answer can be found at
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.2
It does not.
Could anyone please answer if every C++ programs get converted to
equivalent C code during compilation ? Thank you.
Leigh Johnston said:Some early C++ compilers worked this way but I suspect very few modern
C++ compilers produce C as an intermediate but rather create machine
code directly.
Are you suggesting that C++ compilers convert the code to asm, then this asm
code is convert to object code?
Would the same not apply with asm?
Not exactly what he is suggesting, but in process of compiling by
mainstream compilers (GCC, VC++, Borland, ...) there is a step in
which preprocessed C++ code is converted to assembly. The assembler
then converts the 'asm' code into object code.
Jorgen said:Are you sure of that? Going to (e.g.) x86 assembly language and then
invoking the assembler to get x86 object code seems unnecessary
complication. I don't see it mentioned in the "GCC internals" document.
So do, some don't. IIRC, GCC, for example, does, MSVC does not.
Paul said:Object files do not contain machine code.
* Shakes head in disbelief*
http://en.wikipedia.org/wiki/Machine_code.
Leigh Johnston said:Paul Reid is a known troll with limited knowledge and arguing with him
is pointless.
Paul said:You can't implement C++ exception hadling in asm.
Paul said:Don't be an idiot, an object file is not machine code.
An object file contains machine code.Don't be an idiot, an object file is not machine code.
Black is not white, a computer is not a dab radio , is not a telvevison , is
not a toaster.Stop being ridiculous please.
Not exactly what he is suggesting, but in process of compiling by
mainstream compilers (GCC, VC++, Borland, ...) there is a step in
which preprocessed C++ code is converted to assembly. The assembler
then converts the 'asm' code into object code.
Not really. Or rather there is no asm that couldn't be
reverse-engineered back into an equivalent expression in another
higher-level language.
Thus while performing a C++ to C conversion at the source code level
would likely lead to a complete mental collapse, a C++ to asm then asm
to C would be doable - though definitely non-trivial.
Thanks for your information. I personally use MSVC in Wintel platforms.Except, as pointed out elsethread, when object files contain nothing
at all resembling machine code. In byte-code or
link-time-code-generation cases, for example.
MSVC currently compiles for x86, x86-64, IPF and ARM. And in the past
compiled for Alpha, MIPS and PPC. IPF will be moving to the "past"
category in the not too distant future.
Compilers to not output machine code or asm , a compilers output is object
code.
Is this an other idiot thats gonna try and argue that machine code is
object code ?
hardly. Compiling is a pretty information lossy process. The chances
of recovering usable source from machine code is pretty slim.
I'm not convinced disassembly is easier than compiling C++ into C. We
know people can write C++ compilers there are loads around. C-Front
specifically compiled into C. Disassembly is a Hard problem.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.