Answer: the preprocessor is a program that processes the C source code before it is compiled. It carries out the lines beginning with #, called preprocessor directives.
Main types of directives:
- File inclusion:
#include <stdio.h>inserts the contents of the header file into the program. - Macro definition:
#define PI 3.14159replaces everyPIin the code with 3.14159. Macros can also take arguments:#define SQUARE(x) ((x)*(x)). - Conditional compilation:
#if,#ifdef,#ifndef,#else,#endifinclude or leave out parts of the code. - Others:
#undef,#pragma,#error.
Directives do not end with a semicolon. The preprocessor also removes comments. Its output (the expanded source code) is then passed to the compiler.