Hi Guest 1 HomePage 1 Jobs 1 WalkIn 1Articles  

 :) Latest Topic
Introduction to C
History of C Language
C Variables
Variables Types in C
C Identifiers
C Operators
C Comments
ASCII Value C
Constants C
Features of C
Install C Language
Start C Program
Compilation in c
printf() and scanf()
C Data Types
C Keyword
Format Specifier C
Format Specifier part2
Escape Sequence C
Tokens in C
Boolean in C
What are literals?
 


  

 
Compilation in c
Question Posted on 14 Aug 2020

Home >> Tutorial >> C Language >> Compilation in c


Compilation in c
For new developer we must give a simple definition of compilation process. When we write program in C language first of all we will compile it. The compilation is the process to convert source code into object code. And this is done with the help of the compiler. First of all compiler checks the source code for the syntactical or structural errors and if it is error prone then it will create object code.



Compilation in C

This object code is also called machine code which is easily understand by machine. And this compilation process is basicaly divided in 4 steps as given below
(1)Pre-processing or Preprocessor
(2)Compiling or Compiler
(3)Assembling or Assembler
(4)Linking or Linker




Compilation Process

(1)Preprocessor:-First we learn what is source code. Code we write in text editor in C langauge it is called source code. And the extension of this file is ".c". When we compile it then it is first passed to the preprocessor. Processor expand the code and then pass this expand code to the compiler.

(2)Compiler:-When code is expanded by the preprocessor and passed to compiler. Compiler will converts code into assembly code. Or another way we can say C compiler converts the pre--prcoessed code into assembly code.

(3)Assembler:-Here assembly code is now converted into object code by using an assembler. The name of the object file generated by the assembler is the same as the source file. If the name of the source file is 'test.c', then the name of the object file would be "test.obj".

(4)Linker:-All program we written in C use library functions. And these library functions are pre-compiled and object code are stored with ".lib" or ".a" extension. The main working of the linker is to combine the object code of library files with the object code of our program. The output of the linker is the executable file. The name of the executable file is the same as the source file but differs only in their extensions. In DOS, the extension of the executable file is ".exe", and in UNIX, the executable file can be named as "a.out".




Compilation 4 steps

In above flow figure below are the differen steps:-
(1)Firstly we will pass test.c file to proprocessor then it converts the source code into the expanded source code. And the extension of expanded source code would be test.i.
(2)When expanded source code passed to compiler and compiler will converts the expanded source code into assembly code. And extension of assembly code would be test.s.
(3)Assembly code sent to assembler which converts the assembly code into object code. And extension is test.obj.
(4)After creating object code linker creates the executable file. And loader will then load the executable file for the execution.





Other Important Questions
Features of C
Introduction to C
History of C Language
Install C Language
C Variables







 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |