A preprocessor is a text processing program that manipulates
the text within your source file. You enter preprocessing directives
into your source file to direct the preprocessor to perform certain
actions on the source file. For example, the preprocessor can replace
tokens in the text, insert the contents of other files into the
source file, or supress the compilation of part of the file by conditionally
removing sections of the text. It also expands preprocessor macros
and conditionally strips out comments.
Syntax
preprocessor-directive ::=
include-directive newline
macro-directive newline
conditional-directive newline
line-directive newline
error-directive newline
pragma-directive newline
Description
The preprocessing directives control the following general
functions:
Source File Inclusion
You can direct the compiler to include other source files
at a given point. This is normally used to centralize declarations
or to access standard system headers such as stdio.h.
Macro Replacement
You can direct the compiler to replace token sequences with
other token sequences. This is frequently used to define names for
constants rather than hard coding them into the source files.
Conditional Inclusion
You can direct the compiler to check values and flags, and
compile or skip source code based on the outcome of a comparison.
This feature is useful in writing a single source that will be used
for several different computers.
Line Control
You can direct the compiler to increment subsequent lines
from a number specified in a control line.
Pragma Directive
Pragmas are implementation-dependent instructions that are
directed to the compiler. Because they are very system dependent,
they are not portable.
All preprocessing directives begin with a pound sign (#) as the first character in a line of a source
file. White space may precede the # character in preprocessing directives. The # character is followed by any number of spaces
and horizontal tab characters and the preprocessing directive. The
directive is terminated by a new-line character. You can continue directives,
as well as normal source lines, over several lines by ending lines
that are to be continued with a backslash (\).
Comments in the source file that are not passed through the
preprocessor are replaced with a single white-space character.
Examples
include-directive: #include <stdio.h>
macro-directive: #define MAC x+y
conditional-directive: #ifdef MAC
line-directive: #line 5 "myfile"
pragma-directive: #pragma INTRINSIC func