How your code is compiled?

First things first, so
What is a compiler?
Computer software that translates (compiles) source code written in a high-level language.

For example, Your C++ code into a set of machine-language instructions that can be understood by a digital computer’s CPU.

  • Compilers are very large programs, with error-checking and other abilities.
  • Some compilers translate high-level language into an intermediate assembly language, which is then translated (assembled) into machine code by an assembly program or assembler.
  • Other compilers generate machine language directly.

Now for a basic understading let's see how our code is compiled!
image

Here I drawn a small flow diagram of code compilation.
Let me explain it...

  • So, firsty fyour code which is written in HLL gose to a pre-processor, in this step, pre- processor checks your code for File Inclusion( e.g. #include<...>) and Macros definition (e.g. #define Max 1000). The '#' character is a preprocessor directive it is used by preprocessor.
  • As a result we get Pure HLL, now this pure HLL code goes to a compiler which compiles the code and generates its Assembly code.
  • The Assembly code now goes to Assembler which creates the Machine Code.This Machine code is reallocatable, which means during runtime the code can be placed anywhere in the RAM.
  • This Machine code then goes to Linker (or Loader) and then you get the executable code also known as Absolute Machine Code.

If you have any doubts, let me know in the comments.

Comments (0)