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,3332d83c4f455808 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!b28g2000cwb.googlegroups.com!not-for-mail From: "Jerry" Newsgroups: comp.lang.ada Subject: Re: How to use Annex G.3 Vectors and Matrices in bindings to C arrays Date: 13 Nov 2006 21:28:30 -0800 Organization: http://groups.google.com Message-ID: <1163482110.776976.152950@b28g2000cwb.googlegroups.com> References: <1163303134.998680.268570@h54g2000cwb.googlegroups.com> <1163416802.221321.170270@f16g2000cwb.googlegroups.com> <4558aeea$0$20297$426a74cc@news.free.fr> <4558cc70$1_4@news.bluewin.ch> NNTP-Posting-Host: 67.40.87.12 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1163482116 29322 127.0.0.1 (14 Nov 2006 05:28:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 14 Nov 2006 05:28:36 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en-US) AppleWebKit/420+ (KHTML, like Gecko, Safari/420) OmniWeb/v607.5,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: b28g2000cwb.googlegroups.com; posting-host=67.40.87.12; posting-account=Ax24hA0AAABV39UFqUVhb0kauOuAbI3T Xref: g2news2.google.com comp.lang.ada:7442 Date: 2006-11-13T21:28:30-08:00 List-Id: Gautier wrote: > Yves Bailly: > > > So I'm not sure if it's actually possible to correctly pass nD arrays to > > C code... Back again to my OpenGL code, I did things like this: > > type Vector is array(1..3) of Float; > > pragma Convention(C, Vector); > > type Matrix is array(1..3) of Vector; > > pragma Convention(C, Matrix); > > ...and it worked quite well. > > > > But maybe this pragma works for nD arrays? I'm quite interested in the > > answer (I'll test this as soon as I have some time). > > This is at least mentioned in the B.1 annex (verse 2), with exactly the > example of a nD array's storage. > But that works only for constrained arrays--see my reply to Yves for more detail. The whole problem with interfacing to 2D C arrays is that they are constructed as arrays of pointers to other arrays. In Ada, we can mimic this with an unconstrained array of access variables to other other unconstrained arrays of Long_Floats--therein lies the nastiness. > BTW, in my OpenGL code (GLOBE_3D.Math, body) there is... > > type Matrix_44 is array(0..3,0..3) of aliased Real; -- for GL.MultMatrix > pragma Convention(Fortran, Matrix_44); -- GL stores matrices columnwise > Jerry