comp.lang.ada
 help / color / mirror / Atom feed
From: Yves Bailly <kafka.fr@laposte.net>
Subject: Re: How to use Annex G.3 Vectors and Matrices in bindings to C arrays
Date: Sun, 12 Nov 2006 09:45:39 +0100
Date: 2006-11-12T09:46:51+01:00	[thread overview]
Message-ID: <4556df7b$0$30610$426a74cc@news.free.fr> (raw)
In-Reply-To: 1163303134.998680.268570@h54g2000cwb.googlegroups.com

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 | //\
\_/ |                                      | \_/`



  reply	other threads:[~2006-11-12  8:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-12  3:45 How to use Annex G.3 Vectors and Matrices in bindings to C arrays Jerry
2006-11-12  8:45 ` Yves Bailly [this message]
2006-11-13 10:48   ` Jerry
2006-11-12 19:39 ` Jeffrey R. Carter
2006-11-13  7:09   ` tmoran
2006-11-13 11:20   ` Jerry
2006-11-13 17:42     ` Yves Bailly
2006-11-13 19:50       ` Gautier
2006-11-14  5:28         ` Jerry
2006-11-14  5:18       ` Jerry
2006-11-13 19:09     ` Jeffrey R. Carter
2006-11-14  7:31       ` Jerry
2006-11-14  7:54       ` Jerry
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox