Next: Resolving Elaboration Circularities, Previous: Mixing Elaboration Models, Up: Elaboration Order Handling in GNAT [Contents][Index]
If the binder cannot find an acceptable elaboration order, it outputs detailed diagnostics describing an `elaboration circularity'.
package Server is function Func return Integer; end Server;
with Client; package body Server is function Func return Integer is begin ... end Func; end Server;
with Server; package Client is Val : constant Integer := Server.Func; end Client;
with Client; procedure Main is begin null; end Main;
error: elaboration circularity detected info: "server (body)" must be elaborated before "client (spec)" info: reason: implicit Elaborate_All in unit "client (spec)" info: recompile "client (spec)" with -gnatel for full details info: "server (body)" info: must be elaborated along with its spec: info: "server (spec)" info: which is withed by: info: "client (spec)" info: "client (spec)" must be elaborated before "server (body)" info: reason: with clause
In the example above, Client
must be elaborated prior to Main
by virtue
of a `with' clause. The elaboration of Client
invokes Server.Func
, and
static model generates an implicit Elaborate_All
pragma for Server
. The
pragma implies that both the spec and body of Server
, along with any units
they `with', must be elaborated prior to Client
. However, Server
’s body
`with's Client
, implying that Client
must be elaborated prior to
Server
. The end result is that Client
must be elaborated prior to
Client
, and this leads to a circularity.