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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3332d83c4f455808 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news.glorb.com!proxad.net!cleanfeed3-a.proxad.net!nnrp8-1.free.fr!not-for-mail Message-Id: <4556df7b$0$30610$426a74cc@news.free.fr> From: Yves Bailly Subject: Re: How to use Annex G.3 Vectors and Matrices in bindings to C arrays Newsgroups: comp.lang.ada Date: Sun, 12 Nov 2006 09:45:39 +0100 References: <1163303134.998680.268570@h54g2000cwb.googlegroups.com> User-Agent: KNode/0.10.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit Organization: Guest of ProXad - France NNTP-Posting-Date: 12 Nov 2006 09:46:51 MET NNTP-Posting-Host: 81.56.171.53 X-Trace: 1163321211 news-1.free.fr 30610 81.56.171.53:33726 X-Complaints-To: abuse@proxad.net Xref: g2news2.google.com comp.lang.ada:7417 Date: 2006-11-12T09:46:51+01:00 List-Id: Jerry wrote: > with arrays which are (sub)typed from the Annex G.3 declarations. For > example, here is the declaration from the spec of > Ada.Numerics.Generic_Real_Arrays which is GNAT file a-ngrear.ads: Sorry for this off-topic quesiton, but which GNAT version are you using ? I just can't find this file in GNAT-GPL... > type Real_Vector is array (Integer range <>) of Real'Base; > (The Long_Float version, for example, is an instantiation of this > generic and is named Ada.Numerics.Long_Real_Arrays.) > > So--how do I get objects and subtypes based on the type Real_Vector to > have aliased components or, how do I get a type that is type-compatible > with Real_Vector but which has aliased components? > > I wonder if I am incorrect in believing that the binding to C-arrays > need aliased components. Like I said, the reason for that is a little > fuzzy to me right now. But I do know that if I remove the aliased > component requirement from Long_Float_Array_1D the binding will not > compile. Have you tried: type A is array(1..10) of Float; pragma Convention(C, A); The "pragma Convention" might be enough, at least it was when I did some OpenGL programming in Ada, passing Ada vectors or matrices to GL functions. It worked like a charm. > I also wonder if it is generally possible to rationalize other bindings > which involve connecting to C arrays by using (sub)types of the Annex > G.3 vector and matrix types. If not, that would seem to make the Annex > G.3 features useless whenever C array bindings are needed. I can't try (as said, I don't have those Annex G.3-related files), but maybe this works: type C_Real_Vector is new Real_Vector; pragma Convention(C, C_Real_Vector); Though I wonder how the constraint will be handled... Regards, -- (o< | Yves Bailly : http://kafka-fr.net | -o) //\ | Linux Dijon : http://www.coagul.org | //\ \_/ | | \_/`