comp.lang.ada
 help / color / mirror / Atom feed
* Re: Record and Element Sizes Conflict
       [not found] <7tt3qs$5vj$1@schbbs.mot.com>
@ 1999-10-12  0:00 ` Martti Niska
  0 siblings, 0 replies; only message in thread
From: Martti Niska @ 1999-10-12  0:00 UTC (permalink / raw)




"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






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-10-12  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <7tt3qs$5vj$1@schbbs.mot.com>
1999-10-12  0:00 ` Record and Element Sizes Conflict Martti Niska

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