SPL to HP C/XL Migration Guide (30231-90001)
10-4
| | #endif |
| | |
---------------------------------------------------------------------------------------------
| | |
| In a case where two switches are used in | This is rendered in HP C/XL as: |
| series, you might see: | |
| | #if X3 == ON |
| $IF X3 = ON | #define GLOBALVAL 99 |
| DEFINE GLOBALVAL = 99#; | #endif |
| $IF X5 = OFF | #if X5 == OFF |
| DEFINE GLOBALVAL = 101#; | #define GLOBALVAL 101 |
| $IF | #endif |
| | |
---------------------------------------------------------------------------------------------
The conditional compilation facility in HP C/XL is considerably more
powerful than that available in SPL. Instead of ten fixed switches, you
can define arbitrary names as defined variables, and can test an
expression composed of these variables and constants.
The directives "#ifdef
id
" and "#ifndef
id
" are also available to test
whether or not an identifier,
id
, has been defined with a #define
directive. You can use #ifdef and #ifndef in place of #if. See the
HP C
Reference Manual
for more information.
$SET Command (Software Switches for Conditional Compilation)
Table 10-4. $SET Command
---------------------------------------------------------------------------------------------
| | |
| SPL | HP C/XL Equivalent |
| | |
---------------------------------------------------------------------------------------------
| | |
|
set-command
: | Emulated with the #define directive: |
| | |
| $SET [X
n
={OFF | #define X
n
{OFF |
| ON}][,...] | ON} |
| | |
| | [...] |
| | |
---------------------------------------------------------------------------------------------
| | |
| The ten switches, X0,...,X9, used for | The #define directive emulates the $SET |
| conditional compilation are initially set | command. |
| to OFF. | |
| | The syntax above assumes that you have |
| They are turned ON and OFF with the $SET | defined the ten switches and the values ON |
| command. | and OFF at the beginning of the compilation |
| | unit, as follows: |
| | |
| | #define ON 1 |
| | #define OFF 0 |
| | #define X0 OFF |
| | ... |
| | #define X9 OFF |
| | |
---------------------------------------------------------------------------------------------