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,72a0bc6240d264e3 X-Google-Attributes: gid103376,public From: Alfred Hilscher Subject: Re: Access and alias Date: 2000/04/06 Message-ID: <38EC8032.1284C1F0@icn.siemens.de>#1/1 X-Deja-AN: 607516924 Content-Transfer-Encoding: 7bit References: <86d7o5ae23.fsf@ppp-169-201.villette.club-internet.fr> <86aej9aa8y.fsf@ppp-169-201.villette.club-internet.fr> <38EB55AE.D4A241FD@icn.siemens.de> <8cfnpd$3h7$1@nnrp1.deja.com> <38EBBBBE.87C93900@acm.org> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Siemens AG Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-04-06T00:00:00+00:00 List-Id: Jeff Carter wrote: > If you have to pass null, access types (with convention C) work fine. If > you don't have to pass null, in out works for procedures, and access > parameters work for functions. All keep the type checking that addresses > lose: > > -- int func (int* I); > > function F1 (I : System.Address) return Int; > pragma Import (C, F1, "func"); > > function F2 (I : access Int) return Int; > pragma Import (C, F2, "func"); > > I : aliased Int; > J : Int; > S : String := Get; > > ... > > J := F1 (I'Address); -- works as intended > J := F1 (S'Address); -- works as not intended > J := F2 (I'access); -- works as intended > J := F2 (S'access); -- compilation error OK. But I would do a little change: Instead of: function F2 (I : access Int) return Int; pragma Import (C, F2, "func"); Would write type Int_Access is access all INT; function F2 (I : Int_Access) return Int; pragma Import (C, F2, "func"); This avoids some problems that I had with anonymous access types.