C Preprocessors
Preprocessors process directives before compilation.
1. Include Directive
c
#include <stdio.h> // system header
#include "myheader.h" // user header2. Define Directive
c
#define PI 3.14159
#define MAX(a,b) ((a) > (b) ? (a) : (b))3. Conditional Compilation
c
#ifdef DEBUG
printf("Debug mode\n");
#endif
#if VERSION == 1
// version 1 code
#elif VERSION == 2
// version 2 code
#endif4. Undefine
c
#undef PI