10.5. Elaboration of Library Units

[PREVIOUS][UP][NEXT]

Before the execution of a main program, all library units needed by the main program are elaborated, as well as the corresponding library unit bodies, if any. The library units needed by the main program are: those named by with clauses applicable to the main program, to its body, and to its subunits; those named by with clauses applicable to these library units themselves, to the corresponding library unit bodies, and to their subunits; and so on, in a transitive manner.

The elaboration of these library units and of the corresponding library unit bodies is performed in an order consistent with the partial ordering defined by the with clauses (see 10.3). In addition, a library unit mentioned by the context clause of a subunit must be elaborated before the body of the ancestor library unit of the subunit.

An order of elaboration that is consistent with this partial ordering does not always ensure that each library unit body is elaborated before any other compilation unit whose elaboration necessitates that the library unit body be already elaborated. If the prior elaboration of library unit bodies is needed, this can be requested by a pragma ELABORATE. The form of this pragma is as follows:

    pragma ELABORATE (library_unit_simple_name {, library_unit_simple_name});          

These pragmas are only allowed immediately after the context clause of a compilation unit (before the subsequent library unit or secondary unit). Each argument of such a pragma must be the simple name of a library unit mentioned by the context clause, and this library unit must have a library unit body. Such a pragma specifies that the library unit body must be elaborated before the given compilation unit. If the given compilation unit is a subunit, the library unit body must be elaborated before the body of the ancestor library unit of the subunit.

The program is illegal if no consistent order can be found (that is, if a circularity exists). The elaboration of the compilation units of the program is performed in some order that is otherwise not defined by the language.

References: allow, argument of a pragma, compilation unit, context clause, dependence between compilation units, elaboration, illegal, in some order, library unit, name, main program, pragma, secondary unit, separate compilation, simple name, subunit, with clause.


[INDEX][CONTENTS]