comp.lang.ada
 help / color / mirror / Atom feed
From: jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk)
Subject: Access to Address conversion question
Date: 1996/03/21
Date: 1996-03-21T00:00:00+00:00	[thread overview]
Message-ID: <DoMv6y.2p@jvdsys.nextjk.stuyts.nl> (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 --
-----------------------------------------------------------------------




             reply	other threads:[~1996-03-21  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-21  0:00 Jerry van Dijk [this message]
1996-03-22  0:00 ` Access to Address conversion question Norman H. Cohen
1996-03-23  0:00   ` Jerry van Dijk
1996-03-22  0:00 ` Laurent Guerby
replies disabled

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