Introduction to Compiler

The essential thing you need to do, before learning any programming language like C, is to make sure that you have a compiler. For C programming we need to use gcc .

What is a compiler?

Computers understand only 1 language which is consists of sets of instructions made with help of 0 and 1. This language is known as machine language.

A instruction to a computer could look like this:

10001001 01000100

As you can imagine, programming a computer directly in machine language using only ones and zeros is very difficult. To make programming simple and easier , high level languages have been developed. High level programs also make it easier for programmers to understand the program.

#include <stdio.h>
void main()
  {
		int a,b,c;
		printf("Enter value: ");
		scanf("%d%d",&a;,&b;);
		c=a+b;
		printf("Sum= %d",c);
  }

Even if you cannot really understand the code, you should be able to appreciate how much easier it will be to program in the C language as opposed to written in one and zeros.

Computer can only understand one and zeros and humans wish to write in low level languages have to be re-written (translated) into one and zeros at some point. This is done by programs which is known as compiler, interpreter, or assembler.

It turns the program code into an executable that your system can actually understand and run.

How Compiler Works

The Compiler replaces all statements with a sequence of machine instruction. When the program has been compiled the resulting machine code is saved as executable file whose extension is exe.But in system that process also required to do many work which is explained through given image.

Object code file extension

Object file consist of statements and function definition that are defined in ones and zeros. Object files are not executable by themselves. In some operation system the file extension for Object file is .obj and .o

Linker

It is a program that takes one or more object files generated by a compiler or interpreter and combines them into a one executable file.In that process it combine the C library file and object file to create a one executable file with the help of loader which shown in image.

Binary executables file extension (.exe)

.exe file produced as the output of the program which is produced by linker. In unix operating system Binary executable files does not have any extensions. In other operating system like window has .exe as extension.