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,11e34713e74457c X-Google-Attributes: gid103376,public From: Simon Wright Subject: Re: Conversion of access types ... Date: 1997/05/03 Message-ID: #1/1 X-Deja-AN: 239138646 X-NNTP-Posting-Host: pogner.demon.co.uk References: <5k64m8$jv4@taxis.corp.titan.com> Organization: At Home Newsgroups: comp.lang.ada Date: 1997-05-03T00:00:00+00:00 List-Id: t_mjb@linkabit.titan.com writes: > type F is tagged record A: Integer; end record; > type P is access all F; > I am trying to convert a variable of type P to an unsigned long > (ULONG) which will allow me to pass this value on to a system > procedure which will, when the data finally arrives at its > destination, will be converted back into type P. I had a similar problem (calls to my own C procedures, actually, but equivalent) and found that I could declare the C procedure using the Ada access types with pragma Import: type Connection is abstract tagged limited private; type Connection_P is access all Connection'Class; ... type Handler is access procedure (Reason : Call_Reason; On_The_Connection : Peripherals.Connection_P); pragma Convention (C, Handler); function Connect (Name : Interfaces.C.Char_Array; The_Handler : Handler; The_Closure : Connection_P) return Interfaces.C.Int; pragma Import (C, Connect, "connect"); This all works fine on GNAT-3.09 (osf, solaris, linux) but of course there may well be stuff I've failed to understand. For example, what would happen if the pointers were fat? Should I have a pragma Convention (C, Connection_P); ? -- Simon Wright Work Email: simon.j.wright@gecm.com GEC-Marconi Radar & Defence Systems Voice: +44(0)1705-701778 Command & Information Systems Divsion FAX: +44(0)1705-701800