Preprocessor in C
In c programming languages, Preprocessor is a macro processor, processes all the preprocessor directives present in the source code before the compilation. Preprocessor always starts with # sign.
Preprocessor is also called as text substitution tool or CPP.
Preprocessor has following features:
1) Header file inclusion: It includes header files.
2) Macro expansion: It replaces all the macro with the given substituted text.
3) Conditional compilation: allows to add or avoid program part on basis of given condition.
4) Line control: It is called as preprocessor line control directive gives the line number of next source line.
Following are the preprocessor directives:
#define | Substitutes a preprocessor macro |
#include | Inserts a particular header from another file |
#undef | Undefines a preprocessor macro |
#ifdef | if macro is defined, Returns true. |
#ifndef | if macro is not defined, Returns true. |
#if | Checks if a condition is true in compile time. |
#else | The alternative for #if. |
#elif | #else and #if in one statement. |
#endif | Ends preprocessor conditional. |
#error | Prints error message on stderr. |
#pragma | Provides extension specific to the compiler. |