comp.lang.ada
 help / color / mirror / Atom feed
* address clause restrictions
@ 1996-09-28  0:00 Robert Dewar
  0 siblings, 0 replies; only message in thread
From: Robert Dewar @ 1996-09-28  0:00 UTC (permalink / raw)




John said

"X : float := 0;
for X use at memory_manager.next_address( X'size, "SUBSYSTEM.X" );

We use memory_manager to map things to ScramNet.
Gnat insisted that the at value had to be a prior define constant.
So changed the code to:

X_ADDRESS : constant system.address :=
    memory_manager.next_address( X'size, "SUBSYSTEM.X" );

X : float := 0;
for X use at X_ADDRESS;"

Note that the RM specifically permits compilers to reject the first
formulation above, so if you want to write portable Ada 95 code
you should always use the second formulation, with a prior defined
constant.

Actually the particular example above is definitely completely WRONG.
You cannot give an address clause for X after X has been frozen, and
X'Size certainly freezes X, so this is illegal.

Your replacement is equally illegal, since it references X'Address before
X has been declared.

I assume this was just an example of what you meant. Both examples above
should be rejected by GNAT and by any correct Ada 95 compiler.





^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-09-28  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-28  0:00 address clause restrictions Robert Dewar

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