From: "Peter C. Chapin" <pchapin@sover.net>
Subject: Question about circular elaboration order error (GNAT).
Date: Sun, 13 Apr 2008 14:12:34 -0400
Date: 2008-04-13T14:12:34-04:00 [thread overview]
Message-ID: <48024d11$0$19786$4d3efbfe@news.sover.net> (raw)
I'm using GNAT GPL 2007. Consider the following packages. The
specifications and bodies are each in their own files, as usual.
----> parent.ads <----
package Parent is
-- Needed so this package requires/allows a body.
procedure Dummy;
end Parent;
----> parent-child.ads <----
package Parent.Child is
procedure Print_Stuff;
end Parent.Child;
----> parent.adb <----
with Parent.Child;
package body Parent is
procedure Dummy is
begin
null;
end;
begin
Parent.Child.Print_Stuff; -- Note: invoking child here.
end Parent;
----> parent-child.adb <----
with Ada.Text_IO;
package body Parent.Child is
procedure Print_Stuff is
begin
Ada.Text_IO.Put_Line("Printing stuff in package Parent.Child");
end Print_Stuff;
end Parent.Child;
My main procedure just does a "with Parent" but otherwise does nothing
(it contains only a null statement). Note that the elaboration code in
package Parent is calling a subprogram in package Parent.Child. With the
-gnatwl option, GNAT tells me
warning: implicit pragma Elaborate_All for "Parent.Child" generated
when compiling parent.adb. This does not surprise me and seems fine.
However, when trying to build the executable I get:
error: elaboration circularity detected
info: "parent (body)" must be elaborated before "parent (body)"
info: reason: implicit Elaborate_All in unit "parent (body)"
info: recompile "parent (body)" with -gnatwl for full details
info: "parent (body)"
info: must be elaborated along with its spec:
info: "parent (spec)"
info: which is withed by:
info: "parent.child (spec)"
info: which is withed by:
info: "parent (body)"
gnatmake: *** bind failed.
I don't understand where the circularity is coming from. Isn't the
following elaborate order acceptable:
parent (spec)
parent.child (spec)
parent.child (body)
parent (body)
How is it the case that parent (body) must be elaborated before parent
(body)? I've tried tinkering around with some explicit elaboration
related pragmas to control the order of elaboration, but GNAT insists
there is circularity regardless. I'm left with the impression that all
my attempts to control the elaboration order are fruitless.
Note my actual program involves a task in the parent that is trying to
use subprograms in the child. However, the difficulties I'm having
appear to be unrelated to tasking.
Thanks in advance for any thoughts you might have.
Peter
next reply other threads:[~2008-04-13 18:12 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-13 18:12 Peter C. Chapin [this message]
2008-04-13 19:43 ` Question about circular elaboration order error (GNAT) Samuel Tardieu
2008-04-13 20:20 ` Robert A Duff
2008-04-13 21:20 ` Samuel Tardieu
2008-04-14 20:21 ` Robert A Duff
2008-04-14 23:36 ` Adam Beneschan
2008-04-15 7:13 ` Georg Bauhaus
2008-04-13 19:46 ` Robert A Duff
2008-04-13 22:49 ` Peter C. Chapin
2008-04-14 13:56 ` Robert A Duff
2008-04-14 17:33 ` Jeffrey R. Carter
2008-04-14 17:52 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox