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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c4ba91f4ae36a2c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!l2g2000vbn.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: Elaborate_All on child package Date: Sun, 4 Sep 2011 22:21:58 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <19a85f93-3cd2-4054-8022-21ba294d53e3@glegroupsg2000goo.googlegroups.com> NNTP-Posting-Host: 80.156.44.178 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1315200499 19778 127.0.0.1 (5 Sep 2011 05:28:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 5 Sep 2011 05:28:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l2g2000vbn.googlegroups.com; posting-host=80.156.44.178; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESRCNK X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:21816 Date: 2011-09-04T22:21:58-07:00 List-Id: On 3 Sep., 18:57, "Rego, P." wrote: > However, should it be done this way? Due to it is already "withed" to the= parent package, so why have I make a new with? I mean: why is the followin= g code incorrect: > =A0 =A0pragma Elaborate_All (Forum_Test); > =A0 =A0package Forum_Test.Childp is <....> > > and why is the following code correct? > =A0 =A0with Forum_Test; > =A0 =A0pragma Elaborate_All (Forum_Test); > =A0 =A0package Forum_Test.Childp is <....> The simple (and unsatisfying) answer: Because the RM says so. So your problem is based on lack of understanding of elaboration. A program begins execution by elaborating all compilation units. There is no order prescribed for this except that what is mentioned in a context clause must be elaborated before. So applied to your example, elaboration order can be: 1. Forum_Test'Spec 2. Forum_Test'Body 3. Forum_Test.Childp'Spec With this sequence, your program would have worked. However your compiler, GNAT, chose another sequence: 1. Forum_Test'Spec 2. Forum_Test.Childp'Spec 3. Forum_Test'Body When Childp calls Construct, you get an elaboration check that fails. There are several ways to force certain elaboration orders. One is to use pragma Elaborate_Body in every spec whenever the spec defines a function - this forces the body to be elaborated directly after the spec. Sometimes, this is not possible. Other pragmas are Preelaborate, Elaborate_All, Elaborate, Pure. See RM 10.2.1 Elaboration Control.