views:

96

answers:

3

I receive this question in a test:

What are the 5 stages in which a source code is transformed to a executable file?

+3  A: 

One minute on google would have resolved your question

Compiler is the magic word

If your eyes can't find the right line :)

Compilation in general is split into roughly 5 stages:

Preprocessing, Parsing, Translation, Assembling, and Linking.

KroaX
+4  A: 

There can not be fixed 5 steps. Depends on what language is the source code in and what compiler is used.

Hasan Khan
+5  A: 

The five stages are bogus. Standard ML of New Jersey, for example, was at one point a 33-pass compiler, going from source code to machine code (no textual assembly; it blasts machine code right into memory). I doubt there are exactly five representations that the code goes through. In the lcc C compiler there are these representations:

  • Unpreprocessed source
  • Preprocessed source
  • IR Dags
  • Textual assembly
  • Relocatable object code
  • Executable binary

These days most other compilers translate source into abstract syntax, and in fact the designers of lcc said in retrospect that they wish they had used abstract-syntax trees.

This seems like one of those sad situations where you need to find out what your instructor wants to hear and regurgitate it back. And don't take it too seriously.

Norman Ramsey
+1 for "find out what your instructor wants to hear and regurgitate it back". Tongue planted firmly in cheek.
Marc Bollinger