0% found this document useful (0 votes)
23 views2 pages

What Is A Compiler?

Programmers write source code that must be compiled into machine code by a compiler. The compiler translates the high-level language instructions into object code. A linker then combines modules and resolves symbolic addresses to produce the executable machine code that can be run by the processor.

Uploaded by

sameer khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

What Is A Compiler?

Programmers write source code that must be compiled into machine code by a compiler. The compiler translates the high-level language instructions into object code. A linker then combines modules and resolves symbolic addresses to produce the executable machine code that can be run by the processor.

Uploaded by

sameer khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

“Programmers write programs in a form called source code.

Source code must go through several steps


before it becomes an executable program. The first step is to pass the source code through a compiler,
which translates the high-level language instructions into object code. The linker combines modules and
gives real values to all symbolic addresses, thereby producing machine code.”

The above lines explain the entire process of compilation. So basically, you have a program,
called source code, which must undergo the process of compilation to produce an output with the help
of an executable program.

So, if there’s a “compilation” process, there must be a tool to perform this work. Yes, there is one such
thing and it is known by the name of a compiler.

What is a compiler?

A compiler is a special program that processes statements written in a particular programming language
and turns them into machine language or “code” that a computer’s processor uses. Typically, a
programmer writes language statements in a language, such as Pascal or C, one line at a time using
an editor. The file that is created contains what are called the source statements. The programmer then
runs the appropriate language compiler, specifying the name of the file that contains the source
statements.

When executing (running), the compiler first parses (or analyzes) all of the language statements
syntactically one after the other and then, in one or more successive stages or “passes”, builds the
output code, making sure that statements that refer to other statements are referred to correctly in the
final code. Traditionally, the output of the compilation has been called object code or sometimes
an object module. The object code is machine code that the processor can execute one instruction at a
time.

Traditionally in some operating systems, an additional step was required after compilation — that of
resolving the relative location of instructions and data when more than one object module was to be run
at the same time and they cross-referred to each other’s instruction sequences or data. This process was
sometimes called linkage editing and the output known as a load module.

A compiler works with what are sometimes called 3GL and higher-level languages. An assembler works
on programs written using a processor’s assembler language.
How C++ compiles code?

The compilation of a C++ program involves three steps:

1. Preprocessing: the preprocessor takes a C++ source code file and deals with the #include’s, #define’s
and other preprocessor directives. The output of this step is a "pure" C++ file without pre-processor
directives.

2. Compilation: the compiler takes the pre-processor’s output and produces an object file from it.

3. Linking: the linker takes the object files produced by the compiler and produces either a library or an
executable file.

You might also like