HP aC++ predefines the following predicates:

#assert system(unix)

#assert model(lp64) // when +DA2.0W is used

#assert model(ilp32) // default

#assert endian(big)

Example:

int main()

{

#assert dimensions(three) // Set predicate and token to true. #if #dimensions(two)

#error "May not compile in 2 dimensions" #endif

#if #dimensions(three) int x, y, z;

#endif

#unassert dimensions

// Set predicate and all tokens to false.

}

 

Conditional Compilation (#if, #ifdef, .. #endif)

Conditional compilation directives allow you to delimit portions of code that are compiled only if a condition is true.

Syntax

conditional-directive ::=

#if

constant-expression newline

#ifdef

identifier newline [group]

#ifndef

identifier newline [group]

#else

newline [group]

#elif

constant-expression newline [group]

#endif

 

Here, constant-expressionmay also contain the defined operator:

defined identifier

defined (identifier)

The constant-expressionis like other C++ integral constant expressions except that all arithmetic is carried out in long int precision. Also, the expressions cannot use the sizeof operator, a cast, an enumeration constant, or a const object.

Description

You can use #if, #ifdef, or #ifndef to mark the beginning of the block of code that will only be compiled conditionally. An #else directive optionally sets aside an alternative group of statements. You mark the end of the block using an #endif directive.

The following #if directive illustrates the structure of conditional compilation:

#if constant-expression

...

(Code that compiles if the expression evaluates to a nonzero value.)

...

#else

...

(Code that compiles if the expression evaluates to zero.)

126 Preprocessing Directives