Presentation is loading. Please wait.

Presentation is loading. Please wait.

Preprocessor.

Similar presentations


Presentation on theme: "Preprocessor."— Presentation transcript:

1 Preprocessor

2 “definition of preprocessor”
The C preprocessor or cpp is the macro preprocessor for the C and C++ computer programming languages. The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control.

3 “Preprocessor” The “C” preprocessor is a collection of special statement that are accepted at the begging of the process. All the preprocessor statement must beginning with “#” character. #Include : The preprocessor is a rather strange feature of C. It is a non interactive editor, which has been placed on the “front” of the compiler. This handles the “#include” directives by physically inserting the named file into what the compiler will eventually see. #define: As the preprocessor is an editor, it can perform search and replace. To put it in this mode the #define command is used. The syntax is simply : #define search _ text replace _ text

4 Expanded source code (PR1.OBJ) Executable code (PR1.EXE)
Hand written program C Source code (PR1.C) Expanded source code (PR1.OBJ) Object code (PR1.OBJ) Executable code (PR1.EXE)

5 Intermediate (Sometimes “.i”) file
how it works ? We have used the preprocessor since the very fist program , but never looked in detail at what it can do. The preprocessor is little more than an editor placed “in front of” the compiler. Preprocessor Compiler .c file Intermediate (Sometimes “.i”) file

6 INPUT OUTPUT Processor Input Output Editor
Program typed from keyboard. C source code containing program and preprocessor commands. Preprocessor C source code file. Source code file with the preprocessing commands properly sorted out. Compiler Source code file with preprocessing commands sorted out. Relocatable object code. Linker Relocatable object code and the standard C library functions. Executable code in machine language.

7 This character is followed by one of the following preprocessor
#include #define #undef #ifdef #endif #if expression #else #include “filename” #include <filename>

8 Structure of Preprocessor
#include<stdio.h> #include<conio.h> #define P printf #define S scanf #define pi 3.14 int main() { float r; clrscr(); P(“Enter the Perimeter of Circle”); S(“%f”,&r); P(“Perimeter of Circle %f”,2*pi*r); getch(); return 8; }


Download ppt "Preprocessor."

Similar presentations


Ads by Google