From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,691503f3d2c9213d,start X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.glorb.com!newscon02.news.prodigy.net!prodigy.net!news-xxxfer.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Sun, 13 Apr 2008 14:12:34 -0400 From: "Peter C. Chapin" User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Question about circular elaboration order error (GNAT). Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <48024d11$0$19786$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: 271f641a.news.sover.net X-Trace: DXC=K=]J=LLIE[Vc1_L>\3jaRXK6_LM2JZB_S:VSl]>8chbV3?@`i3kGa5[`]df]RZl3>[M2HSMciI] 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