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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,7f18265ce67560b3 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.68.0.170 with SMTP id 10mr1179125pbf.2.1320705774221; Mon, 07 Nov 2011 14:42:54 -0800 (PST) Path: h5ni10204pba.0!nntp.google.com!news1.google.com!postnews.google.com!u10g2000prm.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Memory Access Date: Mon, 7 Nov 2011 14:42:53 -0800 (PST) Organization: http://groups.google.com Message-ID: <8798b68d-b016-47e6-9cf5-326b166bf132@u10g2000prm.googlegroups.com> References: <49f9578c-6f67-4af0-93b0-63120bfe23df@x28g2000prb.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1320705774 4324 127.0.0.1 (7 Nov 2011 22:42:54 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 7 Nov 2011 22:42:54 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u10g2000prm.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: news1.google.com comp.lang.ada:18846 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2011-11-07T14:42:53-08:00 List-Id: On Nov 7, 2:21=A0pm, Adam Beneschan wrote: > > If you known the address of the array data, then something like this > will work even if you don't know the address until runtime: > > =A0 =A0 Data_Address : System.Address; > =A0 =A0 ... > begin > =A0 =A0 -- do some stuff that sets Data_Address to the address. =A0Or you > -- could make > =A0 =A0 -- Data_Address be a parameter to a subroutine, or something > =A0 =A0 -- Then: > > =A0 =A0 declare > =A0 =A0 =A0 =A0Dev_Table : Dev_Table_Type (1 .. Num_Devs_Cnst); > =A0 =A0 =A0 =A0for Dev_Table'Address use Data_Address; > =A0 =A0 begin > =A0 =A0 =A0 =A0-- and you can use Dev_Table in here > =A0 =A0 end; > > This will work whether Num_Devs_Cnst is known at compile time or not. > (The _Cnst makes it look like it's a constant that's known at compile > time. =A0But it doesn't need to be.) An alternative, if you don't want to use an Address clause: with System.Address_To_Access_Conversions; ... Data_Address : System.Address; begin -- set Data_Address to something as above declare subtype Constrained_Dev_Table is Dev_Table_Type (1 .. Num_Devs_Cnst); package Dev_Table_Pointer is new System.Address_To_Access_Conversions (Constrained_Dev_Table); Dev_Table : Dev_Table_Pointer.Object_Pointer :=3D Dev_Table_Pointer.To_Pointer (Data_Address); begin ... end; Dev_Table is now declared as an access (pointer) to a constrained array subtype, rather than an array, but you should still be able to use it in the same way. This method still won't let you create a Dev_Table_Ptr_Type that points to the array, though. -- Adam