HP C/iX Reference Manual (31506-90011)
88 Chapter5
Expressions
Constant Expressions
Constant Expressions
Constant expressions are expressions that can be evaluated during translation rather than
run-time.
Syntax
constant-expression
::=
conditional-expression
Description
A constant expression must evaluate to an arithmetic constant expression, a null pointer
constant, an address constant, or an address constant plus or minus an integral constant
expression.
An integral constant expression must involve only integer constants, enumeration
constants, character constants, sizeof expressions, and casts to integral types. You cannot
include the array subscripting (), member access (. and ->), and address of ()operators in
integral constant expressions. An integral constant expression with the value 0, or such an
expression cast to type void *, is called a null pointer constant. An address constant is a
pointer to an object of static storage duration or to a function designator.
Further, you cannot use a function call, an increment or a decrement operator, or
indirection or assignment operations in a constant expression.
Constant expressions are usually used for "allocation" type operations. An example of this
is array allocation. The size of an array is given as a constant expression.
Examples
2*2
3+3
(-2.5) + 99.8 * 4.5