Preprocessor directives

Preprocessor directive

it is a program that processes source program before being passed to compiler.
The preprocessor statements must begin with #.

Types of preprocessor
1. file inclusion e.g #include
2. Macro expansion e.g #define
3. Conditional compilation e.g. #ifdef, #endif, #if, #elif, #else, #ifndef


1. File inclusion

The #include directive causes one file to be included in another.
General form of #include is:

#include”filename”
#include

e.g.
#include
#include
or
#include”conio.h”


2. Macro Expansion

Macro expansion includes #define statements. It is used to define an identifier and a character string which is substituted for identifier each time it is encountered in the source file.

The general form of :
#define identifier string or value.
e.g.
#define TRUE 1
#define FALSE 0

3. Conditional compilation
If we want to impose something conditionally then #ifdef and #endif preprocessing commands are used.

The general form :

#ifdef macro name
statement 1;
#endif