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 Path: g2news2.google.com!news3.google.com!news.glorb.com!newspeer1.se.telia.net!se.telia.net!masternews.telia.net.!newsb.telia.net.POSTED!not-for-mail From: =?ISO-8859-1?Q?Bj=F6rn_Persson?= User-Agent: Thunderbird 1.5.0.4 (X11/20060614) 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: <1154119563.642347.13670@b28g2000cwb.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Date: Fri, 28 Jul 2006 22:54:30 GMT NNTP-Posting-Host: 83.250.106.238 X-Complaints-To: abuse@telia.com X-Trace: newsb.telia.net 1154127270 83.250.106.238 (Sat, 29 Jul 2006 00:54:30 CEST) NNTP-Posting-Date: Sat, 29 Jul 2006 00:54:30 CEST Organization: Telia Internet Xref: g2news2.google.com comp.lang.ada:6004 Date: 2006-07-28T22:54:30+00:00 List-Id: Jerry wrote: > I would expect that C would simply expect > a blob of MN units of memory where each unit is the sizeof(int) and > rely on M and N being passed as parameters to parse it up correctly. As C, the language, has no concept of two-dimensional arrays, it can't expect anything at all about them. c_plmesh, the function, could have been written to expect this, but according to the declaration you posted it wasn't. > The overall thing I have to figure out, I think, is how to convert a > subtype of Long_Float_Array_2D such as PL_Float_Array_2D into an array > of pointers. I think something like this should work: procedure PLmesh (x : PL_Float_Array; y : PL_Float_Array; z : PL_Float_Array_2D; opt : PLINT) is Pointer_Array : PLFLT_Ptr_Array(z'Range(1)); begin for Index in z'Range(1) loop Pointer_Array(Index) := z(Index, 1)'Access; end loop; c_plmesh(x, y, Pointer_Array, z'Length(1), z'Length(2), opt); end PLmesh; That's just to show the idea. Be sure to check the details carefully, especially in what order the elements of z are stored. -- Bj�rn Persson PGP key A88682FD omb jor ers @sv ge. r o.b n.p son eri nu