comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Re: Getting length of array from C
Date: 01 Feb 2005 05:26:00 +0000
Date: 2005-02-01T05:26:00+00:00	[thread overview]
Message-ID: <x7vlla8df6f.fsf@smaug.pushface.org> (raw)
In-Reply-To: 1107231381.627097.52490@c13g2000cwb.googlegroups.com

"Chuck" <cwinters15@comcast.net> writes:

> Is there some way of getting an ada array length from C interface
> code?  I have to try and accomplish this while minimizing the number
> of changes to the original Ada code.  Any ideas?

Afraid I can't tell which way round you want this to work! Do you have
an Ada array that you need C code to be able to get at, or a C array
that you need Ada code to be able to get at? What's the concept of
operation?

Typically C code needs/can provide the address of the first element of
the array and a count of the number of elements.

Depending on your compiler, you may find something like

  procedure C_Proc (A : My_Array; Count : Integer);
  pragma Import (C, C_Proc, "c_proc");

helpful. You might need to declare a derived array type to get the
representation to be compatible:

  type My_C_Array is new My_Array;
  pragma Convention (C, My_C_Array);

-- 
Simon Wright                               100% Ada, no bugs.



  reply	other threads:[~2005-02-01  5:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-01  4:16 Getting length of array from C Chuck
2005-02-01  5:26 ` Simon Wright [this message]
2005-02-01  7:25 ` Martin Krischik
2005-02-01 13:17   ` Chuck
2005-02-01 14:17     ` Martin Krischik
2005-02-01 20:07     ` Ludovic Brenta
2005-02-07  6:55       ` Dave Thompson
2005-02-02  0:15     ` Jeffrey Carter
2005-02-02  2:22     ` Steve
replies disabled

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