comp.lang.ada
 help / color / mirror / Atom feed
* RE: pragma Import with 'Address clause
@ 2003-03-19 16:59 Beard, Frank Randolph CIV
  2003-03-19 21:03 ` Randy Brukardt
  0 siblings, 1 reply; 10+ messages in thread
From: Beard, Frank Randolph CIV @ 2003-03-19 16:59 UTC (permalink / raw)
  To: comp.lang.ada mail to news gateway

> The Pragma Import should not be needed.

Shouldn't be needed but isn't guaranteed.  The Pragma Import is
there to ensure the compiler doesn't initialize the data.  There
is no guarantee that the compiler won't initialize it to
something, despite the fact the data structure doesn't have a
default expression.

When we were on VAX Ada, it seemed to initialize everything within
the range of the type.  The Alsys Ada, and I think the early versions
of Aonix, we used initialized integers to zero, booleans to FALSE,
etc.  The current version of Aonix does not do the initialization.
We ran into a problem once when upgrading the Aonix compiler.  Code
that used to work began raising CONSTRAINT_ERROR on uninitialized
variables in various places.  I always initialize everything, but
we were working with a team that was new to Ada and weren't 
experienced enough to value the practice.

So, it is better to use the pragma to guarantee the result rather
than hope it always works.  Your compiler vendor may change 
something some day and then your code will suddenly cease to run
properly.

Frank




^ permalink raw reply	[flat|nested] 10+ messages in thread
* pragma Import with 'Address clause
@ 2003-03-19 14:12 Lutz Donnerhacke
  2003-03-19 15:17 ` B0966864
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Lutz Donnerhacke @ 2003-03-19 14:12 UTC (permalink / raw)


A common technique to reinterpret data is:
  a : AT;
  [...]
  b : BT;
  for b'Address use a'Address;
  pragma Import(Ada, b);

Is the "pragma Import" really necessary? Of course, the ARM says, that
elaboration and definition of the imported object is externally defined. So
they are omitted from the Ada code itself.

Assume BT is a record without any default expressions. Does this mean, the
pragma can be omitted from the source code?

Background: Spark prohibits the use of Pragma Import on objects.
  



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-03-21 11:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-19 16:59 pragma Import with 'Address clause Beard, Frank Randolph CIV
2003-03-19 21:03 ` Randy Brukardt
  -- strict thread matches above, loose matches on Subject: below --
2003-03-19 14:12 Lutz Donnerhacke
2003-03-19 15:17 ` B0966864
2003-03-19 16:51 ` Stephen Leake
2003-03-19 17:10   ` Lutz Donnerhacke
2003-03-19 22:29     ` Rod Chapman
2003-03-21 11:13       ` Lutz Donnerhacke
2003-03-19 18:07 ` Rod Chapman
2003-03-21 11:31   ` Lutz Donnerhacke

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