RESERVED attribute
The RESERVED attribute implies STATIC EXTERNAL.
Moreover, if a variable has the RESERVED attribute, the application must comply with the following conditions:
- All declarations of the variable must specify RESERVED.
- The variable name must appear in the RESERVES option of exactly one package.
If a variable has the RESERVED attribute, any INITIAL values are ignored except in the package reserving it.
If a compilation unit has a variable with the RESERVED attribute and is not the reserving package for that variable, that compilation unit must either be part of the load module that contains the reserving package or import the variable from another load module that contains the reserving package. In the latter case, the following conditions apply:
- The declaration for the variable must specify the RESERVED(IMPORTED) attribute.
- The variable must be exported from a DLL.
- The sidefile that is associated with the DLL must be included during the linking of the importing module.
Example
In the following example, the package owns_x
reserves
and initializes the storage for the variable x
. It
must be linked into the same load module as the package owns_y
.
This load module must import the variable z
from
the load module into which package owns_z
is linked.
owns_x:
package
exports(*)
reserves(x);
dcl x char(256) reserved init( ... );
dcl y char(256) reserved init( ... );
dcl z char(256) reserved(imported) init( ... );
end;
owns_y:
package
exports(*)
reserves(y);
dcl x char(256) reserved init( ... );
dcl y char(256) reserved init( ... );
dcl z char(256) reserved(imported) init( ... );
end;
owns_z:
package
exports(*)
reserves(z);
dcl z char(256) reserved(imported) init( ... );
end;