Unary Expressions

A unary expression contains one operand and a unary operator. All unary operators have the same precedence and have right-to-left associativity. A unary expression is therefore a postfix expression.

As indicated in the following descriptions, the usual arithmetic conversions are performed on the operands of most unary expressions.

The following table summarizes the operators for unary expressions:

Precedence and associativity of unary operators
Rank Right Associative? Operator Function Usage
3 yes size of object in bytes sizeof ( expr )
3 yes size of type in bytes sizeof type
3 yes prefix increment ++ lvalue
3 yes prefix decrement -- lvalue
3 yes complement ~ expr
3 yes not ! expr
3 yes unary minus - expr
3 yes unary plus + expr
3 yes address of & lvalue
3 yes indirection or dereference * expr
3 yes C++create (allocate memory)
new type
3 yes C++create (allocate and initialize memory)
new type ( expr_list ) type
3 yes C++create (placement)
new type ( expr_list ) type ( expr_list )
3 yes C++destroy (deallocate memory)
delete pointer
3 yes C++destroy array
delete [ ] pointer
3 yes type conversion (cast) ( type ) expr

C C99 adds the unary operator _Pragma, which allows a preprocessor macro to contain a pragma directive. The operator is supported by IBM C++ as an orthogonal language extension.

XL C/C++ extends the C99 and C++ standards to support the unary operators __real__ and __imag__. These operators provide the ability to extract the real and imaginary parts of a complex type. These extensions have been implemented to ease the porting applications developed with GNU C and C++.

Related References

IBM Copyright 2003