Form
|
Meaning
|
Examples
|
#define
name expansion
|
Whenever name appears in
the source text, replace it with expansion. Expansion ends with the first newline. You can “hide” a newline with the “\”
character, if you want multi-line expansions.
|
#define N 5000
int A[N];
for (i=0; i<N; i++) …
|
#define
name(p1, p2) E
|
Whenever name(E1,E2) appears,
replace it with E but with every occurrence of p1 in E replaced
with E1, and similarly for all other parameters.
|
#define abs(x) \
((x)>0)?(x) : (-x)
|
#include
<filename>
|
Find filename in the
system include library, and replace this #include with the entire file.
|
#include <stdio.h>
|
#include
“filename”
|
Find filename in the current
directory, and replace this #include with the entire file.
|
#include “stack.h”
|
#if constant expression
text1
#elif constant expression
text2
#else
text3
#endif
|
Any number of #elif’s (else if)
lines may appear, and the #else is optional.
This evaluates each constant expression until the first TRUE
(non-zero) value is computed. Then
the entire statement is relaced with the expansion of the text which follows
the TRUE #if or #elif. If none is
found, thetext which follows the #else is used. #defined names may be used in the constant expressions, but no
other names. (The #’s must appear at
the beginning of lines.)
|
#if __ASCII__
int f(i); int i; {
#else
int f(int i) {
#endif
|
#undef name
|
Undefine name.
|
|
#ifdef name
|
Evaluates TRUE if name
is currently preprocessor-defined
|
|