Preprocessor Statements
- Preprocessor – This is a macroprocessor that processes the source program before it is compiled. It is a collection of special statements called preprocesor statements or preprocessor directives.
- These directives are executed before the C program passes through the compiler.
- Preprocessor Directives – These are statements which begin with the # symbol placed in the first coloumn.
- They are placed before the function main().
- There will be no smicolon at the end of such statements.
- Three types -
- Macro substitution directives
- File inclusion directives
- Conditional compilation directives
Macro Substitution
- This is a process of replacing an identifier of a C program by a constant or a symolic constant.
- This can be accomplished by the directive #define.
File Inclusion
- This is a process of inserting the external files containing functions or macro definitions into a C program.
- This process eliminates the job of rewriting the functions or macro definitions.
Conditional Compilation Directives
- C preprocessor provides a conditional compilation directive which is used to select alternate segments of code in a C program depending upon the condition.
- The #ifdef, #else, #elis, #endif directives are used for conditional compilation of the program. These are also used with the #define, #ifndef and #undef directives.
Related posts:








Leave your response!