GupShup Study
 
  
The Compilation Model or Control Flow of a C program
Neeraj Yadav

The Compilation Model or Control Flow of a C program

10-Jul-2016 | | Total View : 334 |

Flow of a C program

 

 

The C program takes after numerous progressions in execution. To comprehend the stream of C program well, let us see a straightforward program first.

We will briefly highlight key features of the C Compilation model here -

#include <stdio.h>  

#include <conio.h>  

void main() {  

printf("Hello GupShupStudy");   

getch();  

}


Let's try to understand the flow of above program by the figure given below. 


 

Normally the C’s program building process involves four stages and utilizes different ‘tools’ such as - 

  1. Preprocessor
  2. Compiler
  3. Assembler
  4. Linker.

1. The Preprocessor -

It processes include-files, conditional compilation instructions and macros. The Preprocessor accepts source code as input and is responsible for

  • removing comments
  • interpreting special preprocessor directives denoted by #.


2. C Compiler -

Compilation is the second pass​. The C compiler translates source to assembly code. The source code is received from the preprocessor. 


3. Assembler -

Assembly is the third stage of compilation. It takes the assembly source code and produces an assembly listing with offsets. The assembler output is stored in an object file.


4. Linker -

Linking is the final stage of compilation. It takes one or more object files or libraries as input and combines them to produce a single (usually executable) file. In doing so, it resolves references to external symbols, assigns final addresses to procedures/functions and variables, and revises code and data to reflect new addresses (a process called relocation).


Hope you like this tutorial, Please share your thoughts by comment section below.

Please Share with your friends.

 

Share With Friends :  

No any Comment yet!