From: aio!dnsurber@eos.arc.nasa.gov (Douglas N. Surber)
Subject: Re: Novice Question on Record Representation
Date: 17 Dec 92 14:29:35 GMT [thread overview]
Message-ID: <dnsurber.724602575@node_26400> (raw)
In <1992Dec16.225712.23791@saifr00.cfsat.honeywell.com> lam@saifr00.cfsat.honey
well.com (Josh Lam) writes:
>There is a type in another package I need to use in a record in my package.
>Unfortunately, that type is private and I need to use record representation
>for my record.
> for My_Rec use record
> A at 0 range 0..15;
> B at 0 range 16..31;
> C at 1 range 0..31; -- of course there is an error here!
> Choice at 2 range 0..31;
> D at 0 range 0..15;
> end record;
Try the following small kludge:
package P1 is
type T is private;
T_Size : constant := 32;
private
type T is new Integer;
subtype Assertion is boolean range true .. true;
a1 : constant Assertion := T_Size = T'Size;
end P1;
with P1;
package P2 is
type T is
record
F : P1.T;
end record;
for T use record
F at 0 range 0 .. P1.T_Size - 1;
end record;
end P2;
You can't use P1.T'Size directly since it isn't static outside of the
private part (at least according to the Alsys compiler). By using the
Assertion, you assure that T_Size has the right value. Yes, you may have
to tweak its value when you port, but you can't get a clean compile with
the wrong value so it is safe.
--
Douglas Surber "Would you rather debug at
Lockheed compile time or run time?"
Houston, TX --Michael B. Feldman
next reply other threads:[~1992-12-17 14:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1992-12-17 14:29 Douglas N. Surber [this message]
-- strict thread matches above, loose matches on Subject: below --
1992-12-18 0:22 Novice Question on Record Representation zaphod.mps.ohio-state.edu!cis.ohio-state.edu!udecc.engr.udayton.edu!black
1992-12-17 22:32 Douglas N. Surber
1992-12-17 18:24 Gary Morris @pulsar
1992-12-17 13:28 agate!spool.mu.edu!sdd.hp.com!saimiri.primate.wisc.edu!aplcen.apl.jhu.edu
1992-12-16 22:57 Josh Lam
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox