Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Question about ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 12 Topic 5651 of 5697
Post > Topic >>

Question about circular elaboration order error (GNAT).

by "Peter C. Chapin" <pchapin@[EMAIL PROTECTED] > Apr 13, 2008 at 02:12 PM

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




 12 Posts in Topic:
Question about circular elaboration order error (GNAT).
"Peter C. Chapin&quo  2008-04-13 14:12:34 
Re: Question about circular elaboration order error (GNAT).
Samuel Tardieu <sam@[E  2008-04-13 21:43:19 
Re: Question about circular elaboration order error (GNAT).
Robert A Duff <bobduff  2008-04-13 16:20:30 
Re: Question about circular elaboration order error (GNAT).
Samuel Tardieu <sam@[E  2008-04-13 23:20:42 
Re: Question about circular elaboration order error (GNAT).
Robert A Duff <bobduff  2008-04-14 16:21:54 
Re: Question about circular elaboration order error (GNAT).
Adam Beneschan <adam@[  2008-04-14 16:36:41 
Re: Question about circular elaboration order error (GNAT).
Georg Bauhaus <rm.tsoh  2008-04-15 09:13:38 
Re: Question about circular elaboration order error (GNAT).
Robert A Duff <bobduff  2008-04-13 15:46:29 
Re: Question about circular elaboration order error (GNAT).
"Peter C. Chapin&quo  2008-04-13 18:49:25 
Re: Question about circular elaboration order error (GNAT).
Robert A Duff <bobduff  2008-04-14 09:56:03 
Re: Question about circular elaboration order error (GNAT).
"Jeffrey R. Carter&q  2008-04-14 17:33:33 
Re: Question about circular elaboration order error (GNAT).
Robert A Duff <bobduff  2008-04-14 13:52:59 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue May 13 16:50:10 CDT 2008.