comp.lang.ada
 help / color / mirror / Atom feed
* Access to Address conversion question
@ 1996-03-21  0:00 Jerry van Dijk
  1996-03-22  0:00 ` Norman H. Cohen
  1996-03-22  0:00 ` Laurent Guerby
  0 siblings, 2 replies; 4+ messages in thread
From: Jerry van Dijk @ 1996-03-21  0:00 UTC (permalink / raw)


It might be just me again, but I cannot figure out how to convert an access 
type to an address, as in assigning Address_C in the code below. GNAT (3.03)
tells me I have an invalid parameter list in the call to To_Address here ?

Of course I realize that although my C background makes me view Some_Object_Ptr
as just an alias for Some_Object'ACCESS it is, in fact, a different type.

However, LRM 13.7.2 (3) led me to believe it should be possible... 

with System.Address_To_Access_Conversions;
with System.Storage_Elements; use System.Storage_Elements;

procedure Demo is

   type Some_Object is array (1..10) of Character;
   type Some_Object_Ptr is access all Some_Object;

   package Some_Object_Conversion is
      new System.Address_To_Access_Conversions(Some_Object);
   use Some_Object_Conversion;

   A_Object     : aliased Some_Object;
   A_Object_Ptr : Some_Object_Ptr := A_Object'ACCESS;

   Address_A, Address_B, Address_C : Integer;

begin
   Address_A := Integer(To_Integer(A_Object'ADDRESS));
   Address_B := Integer(To_Integer(To_Address(A_Object'ACCESS)));
   Address_C := Integer(To_Integer(To_Address(A_Object_Ptr)));
end Demo;

--
-----------------------------------------------------------------------
--  Jerry van Dijk       --   e-mail: jerry@jvdsys.nextjk.stuyts.nl  --
--  Banking Consultant   --              Member Team-Ada             -- 
--  Ordina Finance BV    --    Located at Haarlem, The Netherlands   --
-----------------------------------------------------------------------
-- I do not speak for my employer, my employer does not speak for me --
-----------------------------------------------------------------------




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

end of thread, other threads:[~1996-03-23  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-03-21  0:00 Access to Address conversion question Jerry van Dijk
1996-03-22  0:00 ` Norman H. Cohen
1996-03-23  0:00   ` Jerry van Dijk
1996-03-22  0:00 ` Laurent Guerby

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