comp.lang.ada
 help / color / mirror / Atom feed
From: "Rego, P." <pvrego@gmail.com>
Subject: Elaborate_All on child package
Date: Sat, 3 Sep 2011 09:57:16 -0700 (PDT)
Date: 2011-09-03T09:57:16-07:00	[thread overview]
Message-ID: <19a85f93-3cd2-4054-8022-21ba294d53e3@glegroupsg2000goo.googlegroups.com> (raw)

Hi, 
I'm trying to create a child package from a package which have a class, but it needs the pragma Elaborate_All so 

package Forum_Test is
   type Small_Class;
   type Small_Class_Acc is access all Small_Class;
   task type My_Task_Type (This_Small_Class : access Small_Class);
   type Small_Class is tagged limited
      record
         My_Task      : My_Task_Type (Small_Class'Access);
      end record;

   function Construct return Small_Class_Acc;
end Forum_Test;

package Forum_Test.Childp is
   Small_Obj : Small_Class_Acc := Construct;
end Forum_Test.Childp;

and I got the messages
forum_test-childp.ads:2:35: info: call to "Construct" during elaboration
forum_test-childp.ads:2:35: info: implicit pragma Elaborate_All for "Forum_Test" generated
forum_test-childp.ads:2:35: warning: call to "Construct" in elaboration code requires pragma Elaborate_All on "Forum_Test"

So I included a pragma Elaborate_All in the beginning of the file, but got the 
message
forum_test-childp.ads:1:23: argument of pragma "Elaborate_All" is not withed unit

And finally I 'withed' the child package and it worked as well.

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 following code incorrect:
   pragma Elaborate_All (Forum_Test);
   package Forum_Test.Childp is <....>

and why is the following code correct?
   with Forum_Test;
   pragma Elaborate_All (Forum_Test);
   package Forum_Test.Childp is <....>



             reply	other threads:[~2011-09-03 16:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-03 16:57 Rego, P. [this message]
2011-09-05  5:21 ` Elaborate_All on child package AdaMagica
2011-09-05  9:28   ` Georg Bauhaus
2011-09-10 19:24   ` Rego, P.
2011-09-06  7:05 ` Egil Høvik
2011-09-06 12:51   ` Robert A Duff
2011-09-06 13:46     ` Niklas Holsti
2011-09-06 14:23       ` Robert A Duff
2011-09-07  5:03         ` AdaMagica
2011-09-07 10:49           ` Georg Bauhaus
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox