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!postnews2.google.com!not-for-mail From: fjloma@andaluciajunta.es (Francisco Javier Loma Daza) Newsgroups: comp.lang.ada Subject: Re: C array to ada record interface Date: 22 Jul 2004 11:02:39 -0700 Organization: http://groups.google.com Message-ID: <404ee0af.0407221002.1cfdc21e@posting.google.com> References: <404ee0af.0407141517.30cacac7@posting.google.com> NNTP-Posting-Host: 80.102.44.14 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1090519360 22550 127.0.0.1 (22 Jul 2004 18:02:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 22 Jul 2004 18:02:40 +0000 (UTC) Xref: g2news1.google.com comp.lang.ada:2350 Date: 2004-07-22T11:02:39-07:00 List-Id: Jeffrey Carter wrote in message news:... > 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. Thanks, I think you understood well I would want to use some more ada like array, you suggest to implement that with accesors functions ... I was just wondering if it can be done, the Len + Arr part, to be set up as an Ada array ...