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: cosc19z5@Bayou.UH.EDU (Spasmo) Subject: Re: Gnat For use at Question Date: 1996/07/12 Message-ID: <4s6fk5$du5@masala.cc.uh.edu>#1/1 X-Deja-AN: 168075230 references: <4s2eb5$qt6@masala.cc.uh.edu> organization: University of Houston newsgroups: comp.lang.ada Date: 1996-07-12T00:00:00+00:00 List-Id: Jon S Anthony (jsa@organon.com) wrote: : 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: Well I never said that the error message was unclear, I was however quite unfamiliar with what it was saying. It made mention of a "System.Address", but I couldn't figure out what it meant (I'm an Ada newbie BTW). : 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)) That's exactly what I got. The thing is I don't have the RM so I was unable to look up the specifics. : 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, Ok, I pretty much had an idea about declaring the address as an instance of System.Address and as a constant which is what I did. I also did a with System, or something similar. : with System.Storage_Elements; Ok, I didn't do Storage_Elements; : use System.Storage_Elements; : procedure Junk2 is : Some_Array_Address : constant System.Address := To_Address(16#bbbbb#); Ok, To_Address -- that I didn't do either. : Some_Array : String(1..4000); : for Some_Array'Address use Some_Array_Address; Is the 'Address necessary? Every book I have doesn't mention it but just says for Some_Array. : 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... Hmmmm ok, well here's a question about To_Address. Since PC's use segment, base addressing, is there an overload of To_Address that accepts both a segment and base, or is it up to us to "massage" the number into the proper format for To_Address? Are there any functions that do this "massaging" for us? Thanks for the help. : /Jon : -- : Jon Anthony : Organon Motives, Inc. : 1 Williston Road, Suite 4 : Belmont, MA 02178 : 617.484.3383 : jsa@organon.com -- Spasmo "Here's a present just for you When you open it, you'll be through" "Letter Bomb" by the Circle Jerks