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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a80b2433ed82459a X-Google-Attributes: gid103376,public From: ncohen@watson.ibm.com (Norman H. Cohen) Subject: Re: Access to Address conversion question Date: 1996/03/22 Message-ID: <4iue5g$113p@watnews1.watson.ibm.com>#1/1 X-Deja-AN: 143722499 distribution: world references: organization: IBM T.J. Watson Research Center reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada Date: 1996-03-22T00:00:00+00:00 List-Id: In article , jerry@jvdsys.nextjk.stuyts.nl (Jerry van Dijk) writes: |> 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 ? ... |> |> 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; If AAC is an instance of System.Address_To_Access_Conversions, then AAC.To_Address takes a parameter of type AAC.Object_Pointer. Your actual parameter, A_Object_Ptr, belongs to a distinct access type, Some_Object_Ptr, that you have declared yourself. (Two type declarations always create two distinct types, even if the declarations contain identical definitions.) The fix is to change the declaration of A_Object_Ptr to: A_Object_Ptr : Object_Ptr := A_Object'ACCESS; or, equivalently, to: A_Object_Ptr : Some_Object_Conversion.Object_Ptr := A_Object'ACCESS; -- Norman H. Cohen ncohen@watson.ibm.com