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!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 28 Jul 2006 07:40:11 -0500 Date: Fri, 28 Jul 2006 08:27:51 -0400 From: Jeffrey Creem User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en 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> In-Reply-To: <1154084819.088112.325730@p79g2000cwp.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 24.147.74.171 X-Trace: sv3-qSMYsISFxgoCpqSZRJ8oKRnQCC7erLXG2CnYtsVqOs81zC4k9DJxxFTf++kTF64k4heNXM6lUVNUTVJ!R1IFAMh6SKgp6dkcKj82dpNpfEa/DtFyxHTNNcAs6qcyb8YvBE+fc/ozcQUMQb+LopwKU5tEV5AH!58k= X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:5990 Date: 2006-07-28T08:27:51-04:00 List-Id: Jerry wrote: > In my project to write a binding for a popular plotter written in C, > I've hit a brick wall and the problem might be associated with passing > two-dimensionaal arrays to C. I'm using GNAT on OS X and Xcode. I can > pass one-dimensional arrays OK. Here are the pertinent parts from an > example where the problem happens: > > > The C > > > typedef double PLFLT; > typedef int PLINT; > > void c_plmesh(PLFLT *x, PLFLT *y, PLFLT **z, PLINT nx, PLINT ny, PLINT > opt); > > > > The Ada > > > type Long_Float_Array_1D is array (Integer range <>) of Long_Float; > type Long_Float_Array_2D is array (Integer range <>, integer range <>) > of Long_Float; > > subtype PLINT is Integer; > > subtype PL_Float_Array is Long_Float_Array_1D; > subtype PL_Float_Array_2D is Long_Float_Array_2D; > > procedure plmesh( > x : PL_Float_Array; > y : PL_Float_Array; > z : PL_Float_Array_2D; > nx : PLINT; > ny : PLINT; > opt : PLINT); > pragma Import(C, plmesh, "c_plmesh"); > > > > And the Ugly > > > AdaPLplotProject has exited due to signal 11 (SIGSEGV). > > This appears during the call to plmesh. Any ideas? > > Thanks, > Jerry > Perhaps the C code is not really expecting a two dimensional array but rather an array of pointers to arrays. You could try using some of the in progress/alpha swig work (only in SVN at the moment at gnuada.sf.net) to autogenerate some bindings to the plplot library since plplot appears to come with a SWIG compatible input file. http://plplot.cvs.sourceforge.net/plplot/plplot/bindings/swig-support/ Even if you decide that the swig stuff is not workable yet, perhaps the bindings it creates will be enough to give you a hint as to what the real structure is here.