HP C/iX Reference Manual (31506-90011)
Chapter 7 95
Preprocessing Directives
7 Preprocessing Directives
Preprocessing directives function as compiler control lines. They enable you to direct the
compiler to perform certain actions on the source file. You can use the preprocessing
directives to make a number of textual changes in the source before it is syntactically and
semantically analyzed and translated. Since preprocessing occurs conceptually before the
compilation process, there is generally no relationship between the syntax of a translation
unit and preprocessing directives. There are some restrictions on where #pragma directives
may appear within a translation unit. Refer to chapter 8 for details.
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.sys.
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
Pragmas are implementation-dependent instructions that are directed to the compiler.
Because they are 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. The # character is followed by any number of spaces and horizontal tab