The following article gives detailed information about compilation process in C program as well as C code compiler. Also it represents all steps included in compilation process in C.
Compilation process in c:
Compilation is nothing but the programmer write the code and check it whether correct or not with the use of programming language.
Consider, C Program` code, Like any word document having .docx extension or image with .png / .jpeg extension, it has .C extension. When we test for errors using compiler it converts that programming code into object code as .obj file. This process of conversion is called as compilation.
Compilation process consists of following parts:
- Preprocessor
- Compiler
- Assembler
- Link editor
Steps C compilation model:
The following steps C compilation model.
C Code(welcome.c) —à Preprocessor–à Compiler–à Assembly Code-à Assembler-à Object code (welcome.obj) —à Linker -à Executable (a.out or welcome)
Let’s examine each component in more detail.
- The input of process is C source code file and its result is an executable file.
- Preprocessor uses the source code as input. As name suggest it process the code before compilation. It removes all comments and preprocessor directives.
For example in the welcome.c program, the #include directive is used which include code of the standard I/O(input and output) file, stdio.h. It includes the source code of the stdio.h file into the welcome.c program before transferring it to the compiler.
- Then it transfers the result to the C compiler. The C compiler is converts source code into assembly code.
- Then assembler creates the object code with .obj extension.
- If you have used any library function into source code, link editor combine it with main()function to make an executable file of the program and this link editor is called as the linker.
C code compiler:
We explain each component in detail:
1. Preprocessor
- It is the first stage of compilation.
- In preprocessing stage, each lines starts with # character.
- It is also called as preprocessor commands or preprocessor directives.
- Preprocessor directives are used to reduce the repetition of code using library functions such as:
#include<stdio.h>, #include<conio.h>, #include<math.h>, #include<lib.h>,etc.
- They are not taking part in compilation process.
2. Compiler
Compiler translates the source C language code having header files into assembly code.
3. Assembler
- In this stage, an assembler translates these assembly instructions to object code which means the machine instructions of the computer on which your program is to run on.
- Instructions are stored in object files of each source files. Object file consist of C languages binary code representation from each source file.
Object files contains two sections:
- Text section: containing program instructions. It has only read and execute, and not write permissions.
- Data sections: It has all read, write, and execute permissions.
4. Linker
- From assembly step object code is created containing machine instructions that preprocessor understand but some code is missing or misplaced in order.
- We have to arrange this existing piece code in such a manner that we get executable program, this process of arranging code is called as linking.
- The linker arranges the pieces of object code and also adds pieces containing the instructions for library functions used by the program.
Related Articles:
- Basic Accounting Concepts Part 1
borland turbo cc code compilerc# compilercompilation process in ccompiler designcompiler in computergcc compilerinterpreted languagejavaconline c editoronline c program compilerphp compiler
Compilation process in C | C code compiler
2022-11-15
Computer Basics
No Comments
Admin
The following article gives detailed information about compilation process in C program as well as C code compiler. Also it represents all steps included in compilation process in C.
Compilation process in c:
Compilation is nothing but the programmer write the code and check it whether correct or not with the use of programming language.
Consider, C Program` code, Like any word document having .docx extension or image with .png / .jpeg extension, it has .C extension. When we test for errors using compiler it converts that programming code into object code as .obj file. This process of conversion is called as compilation.
Compilation process consists of following parts:
Steps C compilation model:
The following steps C compilation model.
C Code(welcome.c) —à Preprocessor–à Compiler–à Assembly Code-à Assembler-à Object code (welcome.obj) —à Linker -à Executable (a.out or welcome)
Let’s examine each component in more detail.
For example in the welcome.c program, the #include directive is used which include code of the standard I/O(input and output) file, stdio.h. It includes the source code of the stdio.h file into the welcome.c program before transferring it to the compiler.
C code compiler:
We explain each component in detail:
1. Preprocessor
#include<stdio.h>, #include<conio.h>, #include<math.h>, #include<lib.h>,etc.
2. Compiler
Compiler translates the source C language code having header files into assembly code.
3. Assembler
Object files contains two sections:
4. Linker
Related Articles:
Some More: DBMS/ WT/ DMDW
borland turbo cc code compilerc# compilercompilation process in ccompiler designcompiler in computergcc compilerinterpreted languagejavaconline c editoronline c program compilerphp compiler