How to Understand C++ Compilers

A compiler is a program that translates source code in human-like language into machine instructions. The end product is an executable file. Compilers generate more efficient programs. They can build library files that hide implementation so that those can be linked into the main program. C++ compilation is a process that involves several phases.

Things You'll Need

  • C++ development environment like Microsoft Visual C++
Show More

Instructions

    • 1

      Understand the preprocessor phase. C++ compilers begin compilation by running a simple program called the preprocessor. The preprocessor converts the preprocessor directives and writes the result to an intermediate file. Preprocessor directives are formulas that increase readability in source code and save typing.

    • 2

      Comprehend the scanning phase. This is also called the lexical analysis phase. Here, source code is broken into its ultimate units called tokens. The token can be a keyword, an identifier or a symbol name.

    • 3

      Identify the parsing phase. This is also known as "syntactic analysis." Here, the linear sequence of the tokens from the previous phase is reorganized the into a structure called a parse tree. A parse tree is a structure built by the rules of the formal grammar that defines the syntax of C++.

    • 4

      Learn about the semantic analysis phase. Here the compiler augments the parse tree and builds the symbol table. This phase involves type checking (prevention of errors related to type matching), object binding (connection of definitions to declarations for functions and classes), definite assignment (initialization and operator overloading processing) and the identification of warnings and errors.

    • 5

      Grasp the machine-independent optimization phase. Here a program called a global optimizer is used to produce intermediate code that is optimized for better efficiency.

    • 6

      Review the code generation phase. This is where the intermediate code is transformed into the machine language of the system. This can be either assembly language or machine language. If it's assembly language then the assembler, a program, is executed. In both cases the result is object modules having as extension, ".obj."

    • 7

      Become familiar with "machine-dependent optimization." In this phase the machine code that has been generated is optimized even more.

    • 8

      Familiarize yourself with linking. Here, a program called the linker combines the optimized object modules into an executable program with the familiar ".exe" extension that can be loaded into memory and run by the operating system. The linker resolves references to functions across files such as object modules or library files.

Related Searches:

Resources

Comments

You May Also Like

  • How to Compile a Wedding Program

    The details of the wedding are all coming together beautifully. You've got your venue, the caterer is hired and you even managed...

  • How to Understand Pointers in C

    The C programming language provides you with a data type called a pointer. A pointer "points" to another variable in your software...

  • How to Understand Psychokinesis

    Floating books and small items are a little spooky. Many instance of poltergeists, playful spirits, moving items have been linked to sexually...

  • How to Answer Interview Questions for C Programming Jobs

    A job interview for a C programming position provides an opportunity for you to evaluate a potential employer and meet the programmers...

  • UNIX C Tutorial

    Every Unix system (including Linux) has a C compiler installed by default. Depending on the Unix system you are using, this compiler...

  • How to Compile C Programs Online

    Software engineers and programmers rely on compilers to help them turn their source code into fully functional programs. Compilers are programs that...

  • How to Compile Visual Basic

    Compiling your Visual Basic applications is a process that happens throughout the development phase. You compile applications when debugging, setting flags to...

  • Difference Between Assemblers and Compilers

    Assemblers and compilers are two types of computer programs that serve the same purpose: to convert human-readable code to code that can...

  • How to Understand OBD Codes

    An OBD code scanner can help with engine repairs. It can retrieve both pending codes and trouble codes, giving you a diagnosis...

  • How to Program Games in C++

    C++ is an object-oriented programming language, which means developers use it to build and manage virtual objects made from equally virtual blueprints...

Related Ads

Featured