HP C A.06.05 Reference Manual

Preprocessing Directives
Macro Replacement (#define, #undef)
Chapter 7190
Macro Replacement (#define, #undef)
You can define text substitutions in your source file with C macro definitions.
Syntax
macro-directive
::=
#define
identifier [replacement-list]
#define
identifier
(
[identifier-list]
)
[replacement-list]
#undef
identifier
replacement-list
::=
token
replacement-list token
Description
A #define preprocessing directive of the form:
#define
identifier [replacement-list]
defines the identifier as a macro name that represents the replacement list. The macro name
is then replaced by the list of tokens wherever it appears in the source file (except inside of a
string or character constant, or comment). A macro definition remains in force until it is
undefined through the use of the #undef directive or until the end of the translation unit.
Macros can be redefined without an intervening #undef directive. Any parameters used must
agree in number and spelling, and the replacement lists must be identical. All white space is
treated equally.
The replacement-list may be empty. If the token list is not provided, the macro name is
replaced with no characters.
If the define takes the form
#define
identifier
(
[identifier-list]
)
replacement-list
a macro with formal parameters is defined. The macro name is the identifier and the formal
parameters are provided by the identifier-list which is enclosed in parentheses. The first
parenthesis must immediately follow the identifier with no intervening white space. If there
is a space between the identifier and the (, the macro is defined as if it were the first form and
that the replacement list begins with the ( character.