27 February - 2 March 2012
What is compiler?
A program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instructions. Thus, a compiler differs from an interpreter, which analyzes and executes each line of source code in succession, without looking at the entire program. The advantage of interpreters is that they can execute a program immediately. Compilers require some time before an executable program emerges. However, programs produced by compilers run much faster than the same programs executed by an interpreter.
Every high-level programming language (except strictly interpretive languages) comes with a compiler. In effect, the compiler is the language, because it defines which instructions are acceptable.
Because compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language. For example, there is a FORTRAN compiler for PCs and another for Apple Macintosh computers. In addition, the compiler industry is quite competitive, so there are actually many compilers for each language on each type of computer. More than a dozen companies develop and sell C compilers for the PC.
How Does A Compiler Work In A C++ Program?
A C++ compiler first checks all the syntaxes which are being used in a program. If the syntax is correct then compiler generates an assembly code for assembler.
At the highest level, it takes c++ source code and converts it into code that the machine will understand.
As we all know without compiler we are not able to make a program error free the compiler is resposible to check the syntax from right to left compilation.it tally code with the predefined files which are already defined with the compiler then our source file after the syntax checking is converted into object file ready to execute. When we compile file it send a message to operating system a message 0 or 1,if compiler found program error free then it send message and return o to operating system and for error return 1.




