A compiler is a language translator that converts a complete program written in a high-level programming language into machine code or executable code before the program is run.
A compiler is a language translator that converts a complete program written in a high-level programming language into machine code or executable code before the program is run.
A compiler takes the whole program, translates it, and prepares it for execution.
A computer's CPU executes machine-level instructions, while programmers usually write programs using high-level languages such as C. The compiler acts as a bridge between the two.
A compiler processes the program and performs several stages before producing the final executable or object code.
| Stage | Main Function |
|---|---|
| Preprocessing | Handles directives such as #include and #define. |
| Compilation | Translates source code into lower-level code such as assembly. |
| Assembly | Converts assembly code into object code. |
| Linking | Combines object code with required libraries to create the executable. |
During compilation, the compiler checks the program and reports errors that prevent successful translation. These may include syntax and semantic problems.
Compiler = Translate the complete program first, then execute the generated program.
| Point | Remember |
|---|---|
| Input | High-level source program |
| Translation | Whole program |
| Output | Object / executable code |
| Main Advantage | Fast execution after successful compilation |
| Example | GCC, Clang, MSVC |
After reading the topic, watch an easy explanation of compiler and the compilation process.
A short handwritten-style revision sheet for Compiler and Compilation Process will be provided here.
Use the mind map for quick revision of Compiler, compilation phases and output.