HP-UX Reference (11i v1 05/09) - 1 User Commands A-M (vol 1)

c
cpp(1) cpp(1)
_PA_RISC1_0 _PA_RISC1_1 _SIO _WSIO
UNIX systems variant: hpux _ _hpux _HPUX_SOURCE
PWB _PWB
lint(1): lint _ _lint
In addition, all symbols that begin with an underscore and either an upper-case letter or
another underscore are reserved. Other symbols may be defined by the
CCOPTS variable
or other command-line options to the C compiler at compile time (see cc(1)). All
HP-UX sys-
tems have the symbols
PWB, hpux
, unix, _PWB, _ _hpux, and _ _unix
defined. Each
system defines at least one hardware variant, as appropriate. The lint symbols are defined
when lint(1) is running. See
DEPENDENCIES.
Two special names are understood by
cpp. _ _LINE_ _ is defined as the current line number (as a
decimal integer) as counted by
cpp. _ _FILE_ _
is defined as the current file name (as a C string) as
known by
cpp. They can be used anywhere (including in macros) just as any other defined names.
Directives
All cpp directives start with lines begun by #. Any number of blanks and tabs are allowed between the
#
and the directive. The directives are:
#define name token-string
Replace subsequent instances of name with token-string. token-string can be null.
#define name(arg, ... , arg) token-string
Replace subsequent instances of name followed by a (, a list of comma-separated set of
arguments, and a ) by token-string, where each occurrence of an arg in the token-string is
replaced by the corresponding set of tokens in the comma-separated list. When a macro
with arguments is expanded, the arguments are placed into the expanded token-string
unchanged. After the entire token-string has been expanded,
cpp restarts its scan for
names to expand at the beginning of the newly created token-string.
Notice that there can be no space between name and the (.
#endif [text]
Ends a section of lines begun by a test directive (#if, #ifdef,or
#ifndef). Each test
directive must have a matching
#endif. Any text occurring on the same line as the
#endif is ignored and thus may be used to mark matching #if#endif pairs. This
makes it easier, when reading the source, to match
#if, #ifdef, and #ifndef direc-
tives with their associated
#endif directive.
#elif constant-expression
Equivalent to:
#else
#if
constant-expression
#else
Reverses the notion of the test directive that matches this directive. Thus, if lines previous
to this directive are ignored, the following lines appear in the output, and vice versa.
#if constant-expression
The lines following appear in the output if and only if the constant-expression evaluates to
nonzero. All binary nonassignment C operators, the
?: operator, the unary -, !, and ˜
operators are all legal in constant-expression. The precedence of the operators is the same
as defined by the C language.
There is also a unary operator, defined, which can be used in constant-expression in
these two forms:
defined(name) or defined name. This allows the use of #ifdef
and #ifndef in an #if directive.
Only these operators, integer constants, and names that are known by cpp should be used
in constant-expression. In particular, the sizeof operator is not available.
#ifdef name
Section 1122 Hewlett-Packard Company 2 HP-UX 11i Version 1: September 2005