Next: , Previous: , Up: Elaboration Order Handling in GNAT   [Contents][Index]


9.4 Controlling the Elaboration Order in Ada

Ada provides several idioms and pragmas to aid the programmer with specifying the desired elaboration order and avoiding ABE problems altogether.

The pragmas outlined above allow a server unit to guarantee safe elaboration use by client units. Thus it is a good rule to mark units as Pure or Preelaborate, and if this is not possible, mark them as Elaborate_Body.

There are however situations where Pure, Preelaborate, and Elaborate_Body are not applicable. Ada provides another set of pragmas for use by client units to help ensure the elaboration safety of server units they depend on.

All pragmas shown above can be summarized by the following rule:

`If a client unit elaborates a server target directly or indirectly, then if the server unit requires a body and does not have pragma Pure, Preelaborate, or Elaborate_Body, then the client unit should have pragma Elaborate or Elaborate_All for the server unit.'

If the rule outlined above is not followed, then a program may fall in one of the following states:

Note that one additional advantage of using Elaborate and Elaborate_All is that the program continues to stay in the last state (one or more correct orders exist) even if maintenance changes the bodies of targets.


Next: , Previous: , Up: Elaboration Order Handling in GNAT   [Contents][Index]