One of C's most useful features is its preprocessor. This is a part of compilation which occurs before the main compilation, and performs simple tasks such as including header files. We will only describe two of its features.
#include
The #include preprocessor command inserts a specified file
into the file being compiled. It is often used to include header
files containing many function declarations:
|
#include <catam.h> /* access the CCATSL library */ |
|
#include <stdio.h> |
printf).
#define
The simplest use of the #define pre-processor command looks like:
|
#define MAX_ITERS 1000
/* .. */
int i;
/* .. */
for (i=1; i<=MAX_ITERS; i++) {
/* .. */
}
|
MAX_ITERS with 1000 (this is a common way to define
constants in C). #define can also be used to define
macros which behave like functions, but we will not discuss
these.