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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fc7fc1b95198137d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-30 09:11:22 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3BDEDF1D.14FE7197@Raytheon.com> From: Mark Johnson X-Mailer: Mozilla 4.5 [en] (WinNT; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada Address = C pointer ? References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Tue, 30 Oct 2001 11:10:53 -0600 NNTP-Posting-Host: 192.27.48.44 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 1004461882 192.27.48.44 (Tue, 30 Oct 2001 11:11:22 CST) NNTP-Posting-Date: Tue, 30 Oct 2001 11:11:22 CST Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:15424 Date: 2001-10-30T11:10:53-06:00 List-Id: "M. A. Alves" wrote: > [snip] > I am in fact using Address and Access_To_Address_Conversions(*) because I > simply did not find out how to do the trick otherwise. For example, the C > function is returning an array of unsigned long. I want to access that > array without copying it. How can you do that with Interfaces.C.Strings > or even Interfaces.C.Pointers ? > Reread the implementation advice in B.3.... An Ada parameter of an array type with component type T, of any mode, is passed as a t* argument to a C function, where t is the C type corresponding to the Ada type T. Of course, your mileage may vary - but here's a simple test case that I ran using GNAT on Linux.... a.c... #include void a ( int * x, int * y) { memcpy(y, x, 40); } b.adb... with Text_Io; procedure B is type Xt is array (1..10) of Integer; Y : Xt := (others => 1); Z : Xt := (others => 0); procedure A (X : Xt; Y : Xt); pragma Import(C, A, "a"); begin A(Y, Z); if (Z(1)=1) then Text_Io.Put_Line("Ok"); else Text_Io.Put_Line("Failed"); end if; end B; which after being built runs and prints out "Ok". Good luck. --Mark