HP C A.06.05 Reference Manual
Preprocessing Directives
Overview of the Preprocessor
Chapter 7186
Overview of the Preprocessor
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:
1. 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.
2. 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.
3. 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.
4. Line Control
You can direct the compiler to increment subsequent lines from a number specified in a
control line.
5. Pragma Directive