home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!udecc.engr.udayton.edu!blackbird.afit.af.mil!usafa.af.mil!kirk!cwarack
- From: cwarack@kirkusafa.af.mil (Chris Warack <sys mgr>)
- Subject: Re: Novice Question on Record Representation
- Message-ID: <1992Dec18.002221.17228@usafa.af.mil>
- Sender: cwarack@kirk (Chris Warack <sys mgr>)
- Nntp-Posting-Host: kirk.usafa.af.mil
- Organization: USAF Academy, CO
- References: <1992Dec16.225712.23791@saifr00.cfsat.honeywell.com>
- Date: Fri, 18 Dec 1992 00:22:21 GMT
- Lines: 78
-
- Why do you say, "of course" there is an error in this? You should be able
- to layout a private type just as easily as any other -- of course, you need
- knowledge of that private type which you otherwise might not need; but, you're
- using a rep clause so you must need it.
-
- However, you may be getting an error if your machine's storage unit is a byte
- (like most machines). In this case, you are laying out field A to take bytes
- 0 and 1; field B takes bytes 2 and 3; field C starts with byte 1 again, thus
- takes bytes 1,2,3, and 4. Bytes 1,2,3 are already allocated, however.
- That is an error. If your storage unit is a long word (32 bits), this should
- work...
-
- -- Chris
-
- In article <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.
- |>
- |> package Some_Package is
- |>
- |> type Some_Int is new integer;
- |> for Some_Int'size use 16;
- |>
- |> type Some_Type is private
- |>
- |> -- etc etc
- |>
- |> private
- |>
- |> type Some_Type is new integer;
- |> for Some_Type'size use 32;
- |>
- |> end Some_Package;
- |>
- |>
- |> with Some_Package;
- |> package My_Package is
- |>
- |> type My_Rec (Choice: Boolean := True) is record
- |> case Choice is
- |> when True =>
- |> A : Some_Package.Some_Int;
- |> B : Some_Package.Some_Int;
- |> C : Some_Package.Some_Type;
- |> when False =>
- |> D : Some_Package.Some_Int;
- |> end case;
- |> end 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;
- |>
- |> -- etc etc
- |>
- |> end My_Package;
- |>
- |>
- |> I know that I cannot do the above cos C is of Some_Package.Some_Type which
- |> is a private type.
- |>
- |> So, other than yelling at the person and getting him to change his type
- |> to public, what are my alternatives given that I need to use record
- |> representation. Please also let me know some pros and cons (if any) to any
- |> alternative.
- |>
- |> Thanks in advance!
- |>
- |> --
- |> Josh Lam
- |> Honeywell Inc
- |> lam@saifr00.cfsat.honeywell.com
- |>
-