HP C A.06.05 Reference Manual

Data Types and Declarations
Type Qualifiers
Chapter 3 45
Type Qualifiers
Syntax
type-qualifier
:: =
const
volatile
__restrict (or restrict for C99)
Description
This section describes the type qualifiersvolatile, const and __restrict (or restrict
for C99).
The volatile type qualifier directs the compiler not to perform certain optimizations on an
object because that object can have its value altered in ways beyond the control of the
compiler.
Specifically, when an object's declaration includes the volatile type qualifier, optimizations
that would delay any references to (or modifications of) the object will not occur across
sequence points. A
sequence point
is a point in the execution process when the evaluation of
an expression is complete, and all side-effects of previous evaluations have occurred.
The volatile type qualifier is useful for controlling access to memory-mapped device
registers, as well as for providing reliable access to memory locations used by asynchronous
processes.
The const type qualifier informs the compiler that the object will not be modified, thereby
increasing the optimization opportunities available to the compiler.
An assignment cannot be made to a constant pointer, but an assignment can be made to the
object to which it points. An assignment can be made to a pointer to constant data, but not to
the object to which it points. In the case of a constant pointer to constant data, an assignment
cannot be made to either the pointer, or the object to which it points.
Type qualifiers may be used alone (as the sole declaration-specifier), or in conjunction with
type specifiers, including struct, union,
enum, and typedef. Type qualifiers may also be used in conjunction with storage-class
specifiers.
Use the __restrict type qualifier on the declaration of a pointer type to indicate that the
pointer is subject to compiler optimizations. The restrict is a C99 keyword which only
supported under C99 mode.