Compilation Process In C

Previous: Your First C Program Next: Variables In C 

Compilation refers to the process by which a computer converts a high-level programming language into a machine language that the computer understands. The software which performs this conversion is called as compiler. The compiler checks the source code for syntactical or structural errors and generates the object code if the source code is error-free.



The compilation process is divided into four steps: pre-processing, compilation, assembling, and linking.




Preprocessor

Preprocessor is a macro processor which processes and transform the source file before actual compilation. It expands the code and send it to compiler.

Preprocessing Directives

Lines in your program that begin with '#' are preprocessing directives. The '#' is followed by an identifier, which is the name of the directive. For example, the directive '#define' defines a macro. Whitespace is also permitted before and after the '#' symbol.

Compiler

The expanded code by preprocessor is passed to compiler where it converts pre-processed code into assembly code.

Assembler

An assembler is used to convert assembly code to object code. The assembler generates an object file with the same name as the source file. The object file extension in DOS is '.obj,' and the extension in UNIX is 'o'. If the source file is called 'helloworld.c,' the object file is called 'helloworld.obj.'

Linker

Library files and other object files are linked to the code and code is converted to executable file. The loader will then load the executable file for the execution.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.