HP aC++/HP C A.06.25 Programmer's Guide

Examples
The following examples show valid combinations of conditional compilation directives:
#ifdef SWITCH // compiled if SWITCH is defined
#else // compiled if SWITCH is undefined
#endif // end of if
#if defined(THING) // compiled if THING is defined
#endif // end of if
#if A>47 // compiled if A is greater than 47
#else
#if A < 20 // compiled if A is less than 20
#else // compiled if A is greater than or equal
// to 20 and less than or equal to 47
#endif // end of if, A is less than 20
#endif // end of if, A is greater than 47
Following are more examples showing conditional compilation directives:
#if (LARGE_MODEL)
#define INT_SIZE 32 // Defined to be 32 bits.
#elif defined (PC) && defined (SMALL_MODEL)
#define INT_SIZE 16 // Otherwise, if PC and SMALL_MODEL
// are defined, INT_SIZE is defined
// to be 16 bits.
#endif
#ifdef DEBUG // If DEBUG is defined, display
cout << "table element : \n"; // the table elements.
for (i=0; i << MAX_TABLE_SIZE; ++i)
cout << i << " " << table[i] << \n;
#endif
Line Control (#line)
You can cause HP aC++ to set line numbers during compilation from a number specified
in a line control directive. The resulting line numbers appear in error message references,
but do not alter the line numbers of the actual source code.
Syntax
line-directive ::=
#line digit-sequence [filename]
Description
The #line preprocessing directive causes HP aC++ to treat lines following it in the
program as if the name of the source file were filename and the current line number
were digit-sequence. This serves to control the file name and line number that are given
in diagnostic messages. This feature is used primarily by preprocessor programs that
generate C++ code. It enables them to force HP aC++ to produce diagnostic messages
Overview of the Preprocessor 169