comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Pragma pack
Date: 1997/03/11
Date: 1997-03-11T00:00:00+00:00	[thread overview]
Message-ID: <dewar.858097682@merv> (raw)
In-Reply-To: 01IGC5R855Z6001KU2@EMAIL.AZ.HONEYWELL.COM


Cory said

<<What is the difference (to an individual record like this) between
employing a pragma pack on this record alone, without packing its
component fields, and not using a pack at all?  For example, will
a variable declared to be of this record type be the exact same size
with only the "highest" level pack as with no packs at all?

Also, while I would assume that a 'Size attribute will dynamically
reflect the effect of pragma pack on a type, can anybody confirm to me
that this is actually true, and does the same go for the USE clause?

I realize that implementations of pragmas are more or less up the
compiler writers, so any input, rules of thumb, references, etc,
are welcome....>>

The last paragraph is very wrong. The Ada 95 reference manual is
pretty explit, and in fact answers, quite clearly, the first two
questions, especially if you assume that IA is followed.

The answer to the first question is that the pack at the higher level
definitely has an effect. For example, a record of 8 booleans should
take 8 bits if the record is packed, but may well take 64-bits if
it is not packed.

Packig a record has no effect on the representation of components (this
is IA, but is followed by GNAt and other Ada 95 compilers as far as I
know). So if you want the components individually packed, that must
be done separately.

Yes, of course the 'Size value will reflect the result of such packing.

I suggest rereading the 95 RM carefully in this area!





  reply	other threads:[~1997-03-11  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-10  0:00 Pragma pack C. Berg (602) 436-5290
1997-03-11  0:00 ` Robert Dewar [this message]
1997-03-17  0:00 ` Matthew Heaney
1997-03-17  0:00   ` Robert Dewar
replies disabled

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