Home Show/Hide Menu
C / C++ Tutorials
➜ C / C++ Compiler
➜ Offline Compiler
➜ Online Compiler
➜ C Programming
➜ C++ Programming

C / C++ Compiler

A compiler is a special program that processes Source Code (human readable) written in a particular programming language and turns them into machine language (computer executable) that a computer's processor uses. The C & C++ compiler is a software application that transforms the human readable C / C++ program code to machine language.
When executing source code, the compiler parses (means analyzes) all statements of the source code syntactically one after the other. Then, there are more successive stages to build the output code. Generally, the output of the compilation process has been called object code. There are four phases for a C/C++ program to become an executable:
1) Pre-processing, 2) Compilation, 3) Assembly and 4) Linking.

Pre-processing is the first phase through which source code is passed. This phase includes:
- Removal of Comments,
- Expansion of Macros,
- Expansion of the included files,
- Conditional compilation

The next Compiling step is to compile codefile.i and produce an intermediate compiled output file codefile.s. This file is in assembly level instructions.

In Assembly phase the codefile.s is taken as input and turned into codefile.o by the assembler. This file is converted into machine language, which are machine level instructions.

Linking is the final phase in which all 'function calls' links with their definitions. Linker knows where all of these functions are implemented. Linker adds some extra code to C / C++ program, which is required when the program starts and ends. This extra code is required for setting up the environment like passing command line arguments.


ADVERTISEMENT