Are there any C++ compilers that generate C code?
Are there any C++ compilers that generate C code?
silk.odyssey
Compilers don't generate high level code like C or C++. They generate assembly/machine code. Both C++ and C compile to the same stuff, native code I believe it's called.
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials
Some compiler can generate assembly code and I just thought it would be nice if they produced C code also so that I can understand C++ better
silk.odyssey
You mean convert C++ code to C code? That would be incredibly difficult, especially if your C++ code had classes, multiple inheritance, and stuff like that. I'd say it's not worth your time.
[email protected]
Microsoft Visual Studio .NET 2003 Enterprise Architect
Windows XP Pro
Code Tags
Programming FAQ
Tutorials
I thought maybe the converted code would be simplified but i guess that would not be the case
silk.odyssey
sorry to burst anyones bubble here, but the answer to the original question: Are there any C++ compilers that generate C code?
is YES.
In fact, when C++ was originally created, ALL C++ compilers generated C code. NONE of them went straight to assembly.
That was because a solid C++ standard and compiler had not yet been built, so companies built extensions which allowed people to use the C++ language. Then, when they compiled their code, the first thing the compiler would do would be to run it through a preprocessor which would convert all C++ code to C code, and then compile the C code to assembly.
If you go back far enough you might be able to download one of those original compilers somewhere on the internet.
I've giving up on that. If I find an old compiler it wouldn't compile the code I have anyway
silk.odyssey