comp.lang.ada
 help / color / mirror / Atom feed
From: "Jerry" <lanceboyle@qwest.net>
Subject: Re: How to use Annex G.3 Vectors and Matrices in bindings to C arrays
Date: 13 Nov 2006 21:18:03 -0800
Date: 2006-11-13T21:18:03-08:00	[thread overview]
Message-ID: <1163481483.779394.31000@f16g2000cwb.googlegroups.com> (raw)
In-Reply-To: 4558aeea$0$20297$426a74cc@news.free.fr


Yves Bailly wrote:
> Jerry wrote:
>
> So I'm not sure if it's actually possible to correctly pass nD arrays to
> C code... Back again to my OpenGL code, I did things like this:
> type Vector is array(1..3) of Float;
> pragma Convention(C, Vector);
> type Matrix is array(1..3) of Vector;
> pragma Convention(C, Matrix);
> ...and it worked quite well.
>
> But maybe this pragma works for nD arrays? I'm quite interested in the
> answer (I'll test this as soon as I have some time).
>
Yes, I believe that this should work for constrained arrays.
Unfortunately, the plotter software PLplot (and indeed, any plotter
program) does not know the size of the arrays and so must receive
unconstrained arrays. Ada does not allow arrays which have
unconstrained element types. So, modifying your example above, one
would have
    type Vector is array (Integer range <>) of Float;
which is OK, but then one would want
    type Matrix is array (Integer range <>) of Vector;
which is not allowed because Vector is an unconstrained type.

Jerry




  parent reply	other threads:[~2006-11-14  5:18 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
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 [this message]
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