C Compilation stages basics and function in detail.4 min read

In this tutorial, we are going to learn the fundamentals of software. It is mandatory to know where we are writing our code in a system, and how it is working in a system. These topics are the startup topic to know the compilation stages. And this tutorial contains In-depth knowledge of function.

इस लेख को हिंदी में पढ़ने के लिए, यहाँ क्लिक करें!

Difference between Program, Application, and Process.

Right now the browser you are using it is nothing but an application which usually referred to as an executable file in technical term.

once the program goes to the compiler and compiler will give an executable file. When we are launching that (Opening by double click) executable file it becomes loaded to RAM with the help of Launcher. That currently loaded file becomes a Process. This is how an application becomes a process.


Program Vs Application Vs Process illustration

Some definitions in easy to understand manner.

Program: It is a source code written by the developer.

Application: It is an executable file in which the compiler has translated the source program.

Process: The task running on a RAM is called process.

Different layers in a system

While learning the core language it is important to know where our code is working in the system.

Most of the time we use the user interface part of a software in the application layer. Our terminal software works on the application layer. So this way, we write our code in the application layer of a system.

application layer, kernel layer, hardware layer

Application layer: It is not a core layer. Where we generally work. For example, using Microsoft software, using the Chrome browser, etc.

Kernel layer: It is a Core layer and it provides services. For example, CPU management system, file management, thread management, etc.

Hardware layer: Where the main physical components work. For example, CPU, RAM, hard disk, etc.

More, we will learn in core Linux system tutorials.


there are two types of compilers.

  1. Native compiler
  2. Cross compiler

Native compiler

  • Source code & target hardware both run on the same technology, It requires the same operating system or same platform to run. For example, Windows.
  • It is capable of generating executable files like ‘.exe’ or other extensions.
  • Turbo C and GCC are good examples of a native compiler.
  • Turbo C undergoes different stages (Preprocessor, Translator, Assembler, and Linker) for the compilation process.


Turbo C compilation stages in detail

Cross compiler

  • A cross compiler is a compiler capable of creating executable code for a platform other than the one on which the compiler is running
  • During compilation, we can select the technology (Eg. Intel, ARM…) which the user is going to use.
  • Cross compilers are independent of target hardware and Operating Systems. Moreover, they are generating RAW code, BIN (binary) file, Hex (hexadecimal) of code.
  • Keil is a very good example of a Cross compiler.
NOTE: Turbo C is not having an option for selecting technology-based compilation, unlike keilC.

— — — — —

Why we are using C? 

  1. It is Reusable.
  2. Portability: The same code (maybe some (or) with modification) by using the core’s compiler can be used in different technology.
  3. C language is nearer to assembly code. Eg. In the C program, you can use both C language & Assembly.
NOTE: C language is also called a middle-level language because in a C program we can use both C & Assembly language.

What is a Function?

C language is a block-structured language (C also called Data-oriented language).

Block structured: Every statement for execution must be written inside a function block.

Function block: Function/Subroutine, is a self-contained block, to perform a specific task.

NOTE: Functions are also called as a subroutine.

function calling explanation

In the previous blog, we learned about structure of C.

In short, “main” is calling function green color box and “mul” is called function red color box in the above image.

Read carefully. Technical terms are being used. Very useful in interviews :

“main” is a calling function; “mul” is a called function.

  • When calling function calls a function, then calling function put a holt on its execution, It resumes the execution once called function returns to the calling function.

— — — — —

Why function declaration?

  • A function is an identifier. So, it should be declared so that compiler will know what type of data it is.
  • About identifiers and keywords and tokens we will learn in upcoming tutorials.
NOTE: C instructions are machine independant. Assembly instructions are machine dependant

— — — — —

printf declaration example without the header file

Print function execution without header file

printf execution without header output

Above code is not having any header file but still, it is compiled successfully and printed desired output on the screen. HOW?


Every code goes under certain compilation stages. The solution is explained in detail, in the next part.


  1. revise the Basics of C language.



Leave a Comment