-qpriority (C++ only)
Category
Purpose
Specifies the priority level for the initialization of static objects.
The C++ standard requires that all global objects within the same translation unit be constructed from top to bottom, but it does not impose an ordering for objects declared in different translation units. The -qpriority option allows you to impose a construction order for all static objects declared within the same load module. Destructors for these objects are run in reverse order during termination.
Defaults
The default priority level is 65535.
Parameters
- number
- An integer literal in the range of 101 to 65535. A lower value indicates a higher priority; a higher value indicates a lower priority. If you do not specify a number, the compiler assumes 65535.
Usage
In order to be consistent with the Standard, priority values specified within the same translation unit must be strictly increasing. Objects with the same priority value are constructed in declaration order.
Note: The C++ variable attribute init_priority can
also be used to assign a priority level to a shared variable of class
type. See The init_priority variable attribute for
more information.
Examples
To compile the
file myprogram.C to produce an object file myprogram.o so
that objects within that file have an initialization priority of 2000,
enter:
xlc++ myprogram.C -c -qpriority=2000