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,d9e66bfe9beb10b9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!shaw.ca!elnk-pas-nf1!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: C array to ada record interface References: <404ee0af.0407141517.30cacac7@posting.google.com> In-Reply-To: <404ee0af.0407141517.30cacac7@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Thu, 15 Jul 2004 01:23:02 GMT NNTP-Posting-Host: 63.184.105.160 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.pas.earthlink.net 1089854582 63.184.105.160 (Wed, 14 Jul 2004 18:23:02 PDT) NNTP-Posting-Date: Wed, 14 Jul 2004 18:23:02 PDT Xref: g2news1.google.com comp.lang.ada:2178 Date: 2004-07-15T01:23:02+00:00 List-Id: Francisco Javier Loma Daza wrote: > struct > { > int a,b,c: > int len; > struct b* arr; > } A; > > And I would love to interface in Ada with a record with a discriminant > > type B_array(len: Positive) is record > arr: array of B(1..len); > end record; > > type A(len: Positive) is > a,b,c: Integer; > arr: A(len); > end record; Assuming you meant Arr : B_Array (Len => Len); this won't work. What you have from C is a pointer; the actual array may not even be contiguous with the struct. You'll have to do something like type B_Ptr is access all B; pragma Convention (C, B_Ptr); type A_Info is record A, B, C : Interfaces.C.Int; Len : Interfaces.C.Int; Arr : B_Ptr; end record; pragma Convention (C, A_Info); You only use these types when talking directly to C. For the rest of your application, you use something like the record you presented, and have your operations that talk to C convert between the 2. -- Jeff Carter "This trial is a travesty. It's a travesty of a mockery of a sham of a mockery of a travesty of two mockeries of a sham. ... Do you realize there's not a single homosexual on that jury?" Bananas 27