C preprocessor is a macro processor, which is used by the compiler to make the appropriate changes to the code before the compilation begins.
C preprocessors are not part of the compiler, it is just an additional step that is performed by the C compiler before the compilation. As the name suggests, it instructs the compiler to do some pre-processing before the actual compilation.
All the preprocessor commands begin with the # symbol. The preprocessor directive should always be the first line of the C program.
C Preprocessor directives
#include – Inserts a specified header file into the code. It basically copies the code of specified header file and paste it in the current C file.
#define – It is used to define constant or substitutes a preprocessor macro.
#undef – Undefined a preprocessor macro. Works opposite to the #define directive. It just un-defines the constant or macro defined by #define directive.
#ifdef – The #ifdef preprocessor directive checks if macro is defined by #define. Returns true, if this macro is defined.
#ifndef – It checks if macro is not defined by #define directive. If yes, it executes the code otherwise code defined in #else directive is executed
#if – It evaluates the expression or condition.
#else – It evaluates the expression or condition if the #if directive condition returns false.
#elif – Combination of #if and #else directives.
#endif – Ends the specified preprocessor condition.
#error – Prints error message. The compiler gives fatal error if #error directive is found and skips further compilation process.
#pragma – It is used to issue special commands or additional information to the compiler.