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,546b2e2a44f83809 X-Google-Attributes: gid103376,public From: jsa@organon.com (Jon S Anthony) Subject: Re: Gnat For use at Question Date: 1996/07/11 Message-ID: #1/1 X-Deja-AN: 167850354 sender: news@organon.com (news) references: <4s2eb5$qt6@masala.cc.uh.edu> organization: Organon Motives, Inc. newsgroups: comp.lang.ada Date: 1996-07-11T00:00:00+00:00 List-Id: In article <4s2eb5$qt6@masala.cc.uh.edu> cosc19z5@Bayou.UH.EDU (Spasmo) writes: > I'm trying to create an array at an absolute memory location, but > I keep on getting some error with "expect System.Address blah blah" > whenever I try. Actually, the error messages are _extremely_ clear and tell you _exactly_ what is wrong and even how to fix it: procedure Junk2 is Some_Array : String(1..4000); for Some_Array'Address use 16#bbbbb#; begin null; end; $ gnat junk2.adb junk2.adb:4:36: expected private type "System.Address" junk2.adb:4:36: found type universal integer junk2.adb:4:36: invalid address clause for "Some_Array" junk2.adb:4:36: must be constant defined before "Some_Array" (RM 13.1(22)) As you can see there is even an RM reference. Let's just follow our nose a little on this error trail and see what pops out. The first error sez that at the 16#... stuff location the compiler expected System.Address but found universal integer. Hence, 16#... is a universal integer and it is no good for an address clause. So, you know that you need to make the value an instance of System.Address for it to have a hope of working. Next, the errors say that the clause itself is wrong because it must be a _constant_ defined _before_ the variable to which it applies (Some_Array). Even gives an RM ref for this. So, you now know that you must define the address as a constant before the variable Some_Array and that it must be of type System.Address. So, with System.Storage_Elements; use System.Storage_Elements; procedure Junk2 is Some_Array_Address : constant System.Address := To_Address(16#bbbbb#); Some_Array : String(1..4000); for Some_Array'Address use Some_Array_Address; begin null; end; $ gnat junk2.adb $ The only goofy thing about this I suppose, is that To_Address (which takes integers and returns the proper address) is not defined in System (along with Address) but in the child Storage_Elements. Goodness knows how that happened... /Jon -- Jon Anthony Organon Motives, Inc. 1 Williston Road, Suite 4 Belmont, MA 02178 617.484.3383 jsa@organon.com