home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!cis.ohio-state.edu!sample.eng.ohio-state.edu!purdue!ames!data.nas.nasa.gov!eos!aio!dnsurber
- From: dnsurber@lescsse.jsc.nasa.gov (Douglas N. Surber)
- Subject: Re: Novice Question on Record Representation
- Message-ID: <dnsurber.724602575@node_26400>
- Sender: news@aio.jsc.nasa.gov (USENET News System)
- Organization: Lockheed Engineering and Sciences
- References: <1992Dec16.225712.23791@saifr00.cfsat.honeywell.com>
- Date: 17 Dec 92 14:29:35 GMT
- Lines: 47
-
- In <1992Dec16.225712.23791@saifr00.cfsat.honeywell.com> lam@saifr00.cfsat.honeywell.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
-