1
$\begingroup$

gcc is a collection of compilers, based on the file extension it compiles a source file. But compilers are only supposed to convert a preprocessed code into assembly code. And after that assembling and linking is done and an executable is generated. But several definitions says that compilers are the ones who convert source code into executable code.. i am confused. what actually a compiler is? what is gcc? Can anyone please give me a clear definition? And i have seen in man pages of gcc mentioning the term "compiler proper" what exactly is this?

$\endgroup$
2
$\begingroup$

I'm not sure there is a well accepted definition of compiler. To some extent this is an informal concept, so you can't expect a mathematical definition like that of a derivative.

Judging from GCC documentation, the compiler proper converts (preprocessed) source code into object code. Several object codes are then linked together to an executable by the linker, but that doesn't form part of the compiler proper. The C/C++ preprocessor also doesn't form part of the compiler proper.

The compiler proper is further composed of two parts: a front end and a back end. The front end converts source code into intermediate code, and is language specific. The back end converts intermediate code into machine code, and is machine specific. GCC comes with several front ends and back ends, and this is why it is called a compiler collection.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ Judging from the man pages of gcc they are saying that compiler proper converts preprocessed code into assembly code not in object code. object code is produced by assembler. And then after process of linking the machine code is generated. But you are saying that back-end compiler produces machine code. that's even more confusing. Does compiler proper really produces machine code? $\endgroup$ – Nitin Bhardwaj Dec 27 '16 at 8:13
  • $\begingroup$ I don't think that the distinction between assembly code and object code is very interesting here. It's an implementation issue. It's true that GCC can definitely produce assembly code, if requested. The linker, however, is a truly separate component, and it can in principle link together any object files conforming to its specifications, not only those compiled by GCC. $\endgroup$ – Yuval Filmus Dec 27 '16 at 8:15
  • $\begingroup$ Actually what i am trying to know is that GCC is a compiler or a compiler proper? And the term compiler proper is even accepted or is it roughly used? $\endgroup$ – Nitin Bhardwaj Dec 27 '16 at 8:20
  • $\begingroup$ GCC is a complete tool chain. One of the tools is the "compiler proper". The linker is another part of the tool chain. $\endgroup$ – Yuval Filmus Dec 27 '16 at 8:22
  • $\begingroup$ thanks that's what i wanted to know. One thing more remaining to know that compiler proper is actually a accepted term or is it vaguely used? $\endgroup$ – Nitin Bhardwaj Dec 27 '16 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.