From: Martti Niska <martti.niska@ssf.fi>
Subject: Re: Record and Element Sizes Conflict
Date: 1999/10/12
Date: 1999-10-12T00:00:00+00:00 [thread overview]
Message-ID: <3803381D.8CCDCC94@ssf.fi> (raw)
In-Reply-To: 7tt3qs$5vj$1@schbbs.mot.com
"Dennis Miller
> I have a record whose size does not match the size of all the combined
> members. The record looks like this:
>
> type My_Record_Type is
> record
> member1 : uWord_T;
> member2 : enum1_T;
> member3 : uWord_T;
> member4 : enum2_T;
> member5 : enum3_T;
> member6 : uWord_T;
> member7 : uWord_T;
> end record;
>
> The uWord_T is declared as such:
> type uWord_T is range 0 .. 65535;
> for uWord_T'size use 16;
>
> All of the sizes for the enum#_T types have been set to 32. When you add up
> all the members of the record, the size comes to 160. When I do
> My_Record_Type'size, the size is 192. Where are the extra bits coming from?
> and where are they being added? This was tested on an Ada83 compiler.
>
> Dennis
As Ted Dennison wrote his responce, that it depends about architecture where
you use it. That, I think answer you question, but I just think that have you
try
pragma Pack your type and that way get it size to 160? Pragma Pack minimize
storage size, but could decrease speed of running application (if speed is
critical).
One way to tell your compiler to be smart.
type My_Record_Type is record
member1 : uWord_T ;
...
end record ;
pragma Pack(My_Record_Type) ;
My_Record : My_Record_Type ; -- now size should be 160
Cheers
Martti
parent reply other threads:[~1999-10-12 0:00 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <7tt3qs$5vj$1@schbbs.mot.com>]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox