comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: Imported deferred constant with an address clause legal?
Date: 1999/03/01
Date: 1999-03-01T00:00:00+00:00	[thread overview]
Message-ID: <wccsobp9kqk.fsf@world.std.com> (raw)
In-Reply-To: 36CC51E0.CAA17FB@praxis-cs.co.uk

Rod Chapman <rod@praxis-cs.co.uk> writes:

>   package My_EEPROM is
>      Obj : constant Integer;
>      pragma Import(Assembler, Obj);  -- Assembler? Seems OK...
>      for Obj'Address use System.Storage_Elements.To_Address(...);
>   end My_EEPROM;

That's fine, except you probably want convention Ada rather than
Assembler.  "Ada" means you have arranged for that memory location in
the EEPROM to be represented like the Ada compiler wants.

It's often a good idea to give a pragma Import for a address-claused
thing, because that turns off implicit initialization -- see
AARM-B.1(38,38.a).  If the Ada compiler generates code to implicitly
initialize a ROM, you're in trouble.  Your example uses Integer, so it
doesn't matter, but if it had been an access type, you need the pragma
to turn off null-ing it.

See also AARM-C.6(13, 13.b).  If you say "constant" as above, and some
external code modifies it, you're in trouble unless you also say "pragma
Volatile".

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




      parent reply	other threads:[~1999-03-01  0:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-18  0:00 Imported deferred constant with an address clause legal? Rod Chapman
1999-02-19  0:00 ` Steve Quinlan
1999-02-20  0:00   ` robert_dewar
1999-02-20  0:00     ` Steve Quinlan
1999-02-21  0:00       ` robert_dewar
1999-03-01  0:00 ` Robert A Duff [this message]
replies disabled

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