4 Preprocessing Directives

HP aC++ has its own, internal, preprocessor which is similar to the HP C preprocessor described in the HP C/HP-UX Reference Manual. When you issue the aCC command, your source files are automatically preprocessed.

This Chapter discusses the following topics:

“Overview of the Preprocessor” (page 119)

“Syntax” (page 119)

“Usage Guidelines” (page 119)

“Source File Inclusion (#include, #include_next)” (page 120)

“Macro Replacement (#define, #undef)” (page 121)

“Assertions (#assert, #unassert)” (page 125)

“Conditional Compilation (#if, #ifdef, .. #endif)” (page 126)

“Line Control (#line)” (page 128)

“IOSTREAM Performance Improvement Pragma” (page 129)

“Pragma Directive (#pragma) and _Pragma Operator” (page 129)

“Error Directive (#error)” (page 130)

“Warning Directive” (page 130)

“Trigraph Sequences” (page 130)

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 suppress 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

The general syntax for a preprocessor directive is:

preprocessor-directive ::= include-directive newline macro-directive newline conditional-directive newline line-directive newline pragma-directive newline error-directive newline trigraph-directive newline warning-directive newline

Usage Guidelines

Following are rules and guidelines for using preprocessor directives:

A preprocessor directive must be preceeded by a pound sign (#). White-space characters may precede the # character.

The # character is followed by any number of spaces and horizontal tab characters and a preprocessor directive.

Overview of the Preprocessor 119

Page 119
Image 119
HP C/aC++ for PA-RISC Software manual Preprocessing Directives, Overview of the Preprocessor, Syntax, Usage Guidelines