HP aC++/HP C Programmer's Guide (B3901-90036; A.06.26; September 2011)
Using the #elif Directive
The #elif constant-expression directive tests whether a condition of the previous #if,
#ifdef, or #ifndef was false. #elif has the same syntax as the #if directive and
can be used in place of an #else directive to specify an alternative set of conditions.
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]
158 Preprocessing Directives