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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f68f726841b97b19 X-Google-Attributes: gid103376,public From: David Botton Subject: Re: Get a pointer to an array Date: 1999/06/06 Message-ID: <375A9D4D.EA452F69@Botton.com>#1/1 X-Deja-AN: 486344676 Content-Transfer-Encoding: 7bit References: <37599022.C77585D@barak-online.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@gate.net X-Trace: news.gate.net 928685394 32124 199.227.148.26 (6 Jun 1999 16:09:54 GMT) Organization: CyberGate, Inc. Mime-Version: 1.0 NNTP-Posting-Date: 6 Jun 1999 16:09:54 GMT Newsgroups: comp.lang.ada Date: 1999-06-06T16:09:54+00:00 List-Id: 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.