comp.lang.ada
 help / color / mirror / Atom feed
* Elaborate_All on child package
@ 2011-09-03 16:57 Rego, P.
  2011-09-05  5:21 ` AdaMagica
  2011-09-06  7:05 ` Egil Høvik
  0 siblings, 2 replies; 10+ messages in thread
From: Rego, P. @ 2011-09-03 16:57 UTC (permalink / 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 <....>



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2011-09-10 19:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-03 16:57 Elaborate_All on child package Rego, P.
2011-09-05  5:21 ` 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

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