On 28/12/10 16:35, Bill McEnaney wrote:
David Brown wrote:
First, you have to understand what a compiler actually is. It is a
program that takes C source code, and generates machine-executable
object code. There is no such thing as a "gui" compiler, or
"windows-style" compiler - compilers are by their nature command-line
programs. They are run with various options, read some files in, and
write files out. There is no need nor use of a gui here, and no serious
compiler attempts to have such a windowed or graphics interface.
Please correct me if I'm wrong when I think that gcc's C compiler generates assembly language
program that as, the assembler, translates in machine language. Thanks.
Yes, you are correct. I was simplifying the process to make it easier
to understand. There are a number of distinct steps taken to convert
from C source code to a runable binary. Some compilers treat this all
as one process, others (such as gcc) divide it up. Most (but not all)
compilers separate the actual compilation to object code from the
linking process. Some (such as gcc) separate the compilation to
assembly code and the assembler pass. gcc also separates the
pre-processor pass from the compilation proper. And if you are using
LTO, everything then goes around in a circle. I have no doubt missed
out passes or steps that the gcc experts could fill in (such as "collect2").
But the one of the very nice features of gcc is that the gcc executable
itself acts as a driver, and hides all this messy detail from the user.
One simply calls "gcc hello.c -o hello", and gcc controls the various
programs for you. Thus you can pretend it is a single program that does
the whole job.