comp.lang.ada
 help / color / mirror / Atom feed
From: jsa@organon.com (Jon S Anthony)
Subject: Re: Gnat For use at Question
Date: 1996/07/11
Date: 1996-07-11T00:00:00+00:00	[thread overview]
Message-ID: <JSA.96Jul11143114@organon.com> (raw)
In-Reply-To: 4s2eb5$qt6@masala.cc.uh.edu


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





  reply	other threads:[~1996-07-11  0:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-11  0:00 Gnat For use at Question Spasmo
1996-07-11  0:00 ` Jon S Anthony [this message]
1996-07-11  0:00   ` Robert A Duff
1996-07-12  0:00   ` Robert Dewar
1996-07-12  0:00   ` Spasmo
1996-07-12  0:00   ` Laurent Guerby
1996-07-13  0:00     ` Jerry van Dijk
1996-07-15  0:00     ` Spasmo
1996-07-12  0:00   ` Jon S Anthony
1996-07-15  0:00   ` Jon S Anthony
1996-07-15  0:00   ` Jon S Anthony
1996-07-15  0:00     ` Jerry van Dijk
1996-07-15  0:00     ` Spasmo
1996-07-15  0:00     ` Robert Dewar
1996-07-11  0:00 ` Jerry van Dijk
1996-07-11  0:00 ` Robert Dewar
1996-07-19  0:00   ` Spasmo
1996-07-11  0:00 ` Robert A Duff
replies disabled

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