Before the C program is compiled with the C compiler, the source code is pre-processed by the program called preprocessor. This process is called preprocessing. Commands used for preprocessing purposes are called preprocessor directives. They begin with a # symbol. Some common preprocessor directives are listed below.
Preprocessor | Syntax/Description |
---|---|
Macro (An abbreviated name given is called macro) | #define This macro defines the constant value that can be any of the basic data types. |
Header file | #include <file_name_with_path> This is used to include or pull the default or user-defined libraries. |
Conditional Preprocessing/Compilation | #ifdef, #endif, #if, #else, #ifndef These are used for conditional preprocessing purposes |
Other Directives | #undef, #pragma |
Example
#include <stdio.h>
// including math.h library
#include <math.h>
// defining symbolic constant for PI
#define PI 3.1416
int main(){
return 0;
}