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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a71fc4911021ed50 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news2.google.com!news.maxwell.syr.edu!transit.news.xs4all.nl!195.241.76.212.MISMATCH!tiscali!transit1.news.tiscali.nl!dreader2.news.tiscali.nl!not-for-mail Newsgroups: comp.lang.ada Subject: Re: Returning data from Ada to C References: <1115164192.585409.163780@z14g2000cwz.googlegroups.com> <9vYde.5480$GQ5.3731@newsread1.news.pas.earthlink.net> <4f1a9$4278d210$cf702d0d$18288@PRIMUS.CA> <1115503927.228956.100050@z14g2000cwz.googlegroups.com> <87is1thimt.fsf@insalien.org> <87ekchhiiq.fsf@insalien.org> <1115678988.738692.53950@z14g2000cwz.googlegroups.com> From: Ludovic Brenta Date: Tue, 10 May 2005 14:48:11 +0200 Message-ID: <87is1rdz78.fsf@insalien.org> User-Agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:mCP/v9d6XbkLZjvCWhz8Z23Jgns= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tiscali bv NNTP-Posting-Date: 10 May 2005 14:48:12 CEST NNTP-Posting-Host: 83.134.244.177 X-Trace: 1115729292 dreader2.news.tiscali.nl 1357 83.134.244.177:33455 X-Complaints-To: abuse@tiscali.nl Xref: g2news1.google.com comp.lang.ada:10984 Date: 2005-05-10T14:48:12+02:00 List-Id: writes: > Ludovic Brenta wrote: >> Ludovic Brenta writes: >> > procedure Hello_World (I : in out Integer; >> > A_Ptr : out C_IntArrs.Pointer) is >> > type Array_Access is access C_Integer_Arrays.C_Integer_Array; >> > Result : Array_Access := new C_Integer_Arrays.C_Integer_Array' >> > (0 => 3, 1 => 2, 2 => 1); >> > begin >> > return Result (Result'First)'Access; >> -- the above is wrong! >> A_Ptr := Result (Result'First)'Access; -- correct >> > end Hello_World; >> >> obviously. > > I had to use Unchecked_Access instead of Access (gnat complained > "non-local pointer cannot point to local object"), but it worked! If you move the type declaration outside of the procedure, then 'Access becomes legal. The best would be to declare Array_Access in C_Integer_Arrays. -- Ludovic Brenta.