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,6b3a3c920575b35a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!attbi_s72.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How to pass two dimensional arrays to C References: <1154084819.088112.325730@p79g2000cwp.googlegroups.com> <1154119563.642347.13670@b28g2000cwb.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.176 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s72 1154211127 12.201.97.176 (Sat, 29 Jul 2006 22:12:07 GMT) NNTP-Posting-Date: Sat, 29 Jul 2006 22:12:07 GMT Date: Sat, 29 Jul 2006 22:12:07 GMT Xref: g2news2.google.com comp.lang.ada:6021 Date: 2006-07-29T22:12:07+00:00 List-Id: Simon Wright wrote: > > I would have thought that, provided you choose the right orientation, > the rows would be as expected by C (ie contiguous values). > > In > > type M is array (Integer range <>, Integer range <>) of Float; > -- Column Row > > the Row elements would be contiguous? (I can see there _might_ be > compiler differences, and ISTR that GNAT has a way of specifying > Fortran conventions). The 1st dimension is considered to index the rows and the 2nd, the columns (from the mathematical notation for 2D matrices). In Ada, all the components of the 1st row are stored in sequence, followed by all the components of the next row, and so on. "An implementation should normally represent multidimensional arrays in row-major order, consistent with the notation used for multidimensional array aggregates (see 4.3.3). However, if a pragma Convention(Fortran, ...) applies to a multidimensional array type, then column-major order should be used instead (see B.5, ``Interfacing with Fortran'')." (ARM 3.6.2). (Note that convention FORTRAN is defined by the language, not GNAT specific.) In other words, the 2nd, or column, index varies most quickly with increasing address. So to my mind, and using the notation I've described here, the row elements are contiguous. So I don't know whether we agree or disagree. -- Jeff Carter "Whatever it is, I'm against it." Horse Feathers 46