C/C++ Programmer's Guide (G06.25+)
C and C++ Extensions
HP C/C++ Programmer’s Guide for NonStop Systems—429301-008
2-19
Operators
type-name
is the name of a type.
unary-expression
is a unary expression.
Usage Guideline
The _bitlength() operator cannot be applied to an operand of function type or of
incomplete type. If this application is attempted, the result is an unsigned constant
whose type is size_t.
_optional()
The _optional() operator is similar to the pTAL $OPTIONAL standard function. It
allows you to dynamically pass and omit actual parameters to extensible and variable
functions.
The first expression operand is a scalar expression that is evaluated to determine
whether an actual argument is to be evaluated and passed to the extensible or variable
function. If the first expression is zero, the second expression operand is not evaluated
and no actual argument is passed. If the first expression is not zero, the second
expression operand is evaluated and passed as the actual argument.
When the _optional() operator is used, the extensible and variable mask and count
words are computed at run-time. The code generated is slightly slower than using
“normal” calls where the mask word and count words are computed at compile time.
Usage Guidelines
•
The _optional() operator can be used only as an actual argument to a variable
or extensible function.
•
The first expression must be scalar.
Examples
This example shows a caller of an extensible function that dynamically decides to pass
one of its arguments.
_extensible foo (int, int, int);
void bar (int i) {
/* Pass a third argument of 30 to foo only if i is not zero.
*/
foo (10, 20, _optional (i, 30));
}
_optional ( expression1, expression2 )