comp.lang.ada
 help / color / mirror / Atom feed
From: David Botton <David@Botton.com>
Subject: Re: Get a pointer to an array
Date: 1999/06/06
Date: 1999-06-06T16:09:54+00:00	[thread overview]
Message-ID: <375A9D4D.EA452F69@Botton.com> (raw)
In-Reply-To: 37599022.C77585D@barak-online.net

You take the access/address of the first element.
a(1)'address or a(1)'access in your code.

And to get back from an address/access to an array you should use the
Interfaces.C.Pointers generic package. (see
http://www.adapower.com/os/com-bstr.html for an example of using
Interfaces.C.Pointers)

Also not if you are trying to work with C:

RM B.3:70

An Ada parameter of an array type with component type T, of any mode, is
passed as a t* argument to a C function, where t is the C type
corresponding to the Ada type T.


David Botton


Elad Rosenheim wrote:
> 
> This question may seem easy, but I haven't been able to find
> a solution:
> 
> How do I create a normal array, then point an access type to it?
> I tried to convert the array 'address attribute to the array access
> type,
> but it didn't work. I think ADA arrays have some "meta data" before
> the data that contains the array bounds, and the 'address attribute
> gives the address of the data storage itself. So how can I make the
> access
> variable point to the array?
> 
> This doesn't work:
> 
>     type int_array is array(integer <>) of integer;
>     type int_access is access int_array;
> 
>     function To_Int_Access is new Unchecked_Conversion(
>         system.address, int_access);
> ...
> 
> declare
>     a : int_array(1..10);
>     b : int_access;
> begin
>     a :=  To_Int_Access(a'address);
> ...
> 
> Please help me with this one.
> 
> Thanks,
> Elad Rosenheim.




  parent reply	other threads:[~1999-06-06  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-05  0:00 Get a pointer to an array Elad Rosenheim
1999-06-06  0:00 ` Robert Dewar
1999-06-06  0:00 ` David Botton [this message]
1999-06-09  0:00 ` Steve Doiel
replies disabled

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