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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,aa7b0448abeecbba X-Google-Attributes: gid103376,public From: kst@thomsoft.com (Keith Thompson) Subject: Re: How to print Task_ID type? (GNAT SunOS) Date: 1996/04/05 Message-ID: #1/1 X-Deja-AN: 145939927 sender: news@thomsoft.com (USENET News Admin @flash) x-nntp-posting-host: pulsar references: <316308F0.6375@ee.ubc.ca> <31642F61.1D2B@ee.ubc.ca> organization: Thomson Software Products, San Diego, CA, USA newsgroups: comp.lang.ada originator: kst@pulsar Date: 1996-04-05T00:00:00+00:00 List-Id: In <31642F61.1D2B@ee.ubc.ca> Greg Bond writes: [...] > Indeed it is. My oversight. This function does not handle the more > general problem I posed though. Is there a general facility for printing > access types? Not directly. Unchecked_Conversion to an integer type (signed or unsigned) of the same size, followed by 'Image on the integer type, is likely to give you what you're probably looking for on most or all implementations. Be aware, though, that there's no guarantee that there is an integer type of the same size as a given access type, or that all access types are the same size (for example, GNAT uses 64-bit "fat pointers" for access to unconstrained arrays). Another possibility is something like this: declare P: Some_Access_Type := Some_Value; package SSE renames System.Storage_Elements; begin if P = null then Put_Line("P = null"); else Put_Line("P = " & SSE.Integer_Address'Image (SSE.To_Integer(P.all'Address))); end if; end; Note, however, that the value stored in an access object isn't necessarily the address of the designated object. It could include or point to a descriptor, among many other possibilities. The generic package System.Address_To_Access_Conversions includes a function to convert from an access type to System.Address, which can then be converted to an integer type by System.Storage_Elements.To_Integer. However, System.Address_To_Access_Conversions only uses the access type Object_Pointer, which it declares itself; it won't operate on an arbitrary access type. A more relevant question might be, why do you want to print access types? If you just want to display them for debugging purposes, a non-portable solution involving Unchecked_Conversion is probably good enough. If you have something else in mind, perhaps you're trying to solve the wrong problem. -- Keith Thompson (The_Other_Keith) kst@thomsoft.com TeleSoft^H^H^H^H^H^H^H^H Alsys^H^H^H^H^H Thomson Software Products 10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2718 This sig uses the word "Exon" in violation of the Communications Decency Act.