From: "Smark" <not.provided@all.com>
Subject: Re: How to convert record?
Date: Fri, 26 Oct 2001 03:21:09 GMT
Date: 2001-10-26T03:21:09+00:00 [thread overview]
Message-ID: <FE4C7.31012$pb4.15204037@news2.rdc2.tx.home.com> (raw)
In-Reply-To: %oWB7.96$xS6.155@www.newsranger.com
"Ted Dennison" <dennison@telepath.com> wrote in message
news:%oWB7.96$xS6.155@www.newsranger.com...
> In article <mailman.1004014779.9400.comp.lang.ada@ada.eu.org>, sk says...
> >
> >-- ... Use 'Size on a _variable_ of that type, not the type itself,
> >-- and divide by System.Storage_Unit (i.e., 8). ...
> >
> >Why variable and NOT type ?
>
> Because the type will return the number of bits it could theoreticly fit
into,
> not the number it takes up. Thus you could get a result that isn't evenly
> divisible by your storage unit (usually 8).
>
> Personally, I prefer to just adjust for that, rather than worry about it.
>
> (Typename'size + System.Storage_Unit - 1) / System.Storage_Unit
>
Well, would you worry about it with a type like this:
type Bubba_Type is record
C : Character; -- one byte
I : Integer; -- 4 bytes
end record;
Bubba : Bubba_Type;
Suppose that Integers must align on 4-byte boundaries. Then you might get:
Bubba_Type'Size = 40 (= 5 bytes)
(Typename'size + System.Storage_Unit - 1) / System.Storage_Unit
= ( 40 + 8 - 1)/8 = 47/8 = 6 (bytes)
But actually:
Bubba'Size = 64 (= 8 bytes)
GNAT provides a nice attribute 'Object_Size that can be used on the type to
give you what the size of an object of that type would be.
Markku Kotiaho
next prev parent reply other threads:[~2001-10-26 3:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-21 9:56 How to convert record? Joseph Kwan
2001-10-22 11:30 ` John McCabe
2001-10-25 11:40 ` Joseph Kwan
2001-10-25 12:38 ` sk
2001-10-25 17:12 ` Jeffrey L. Susanj
2001-10-25 12:48 ` David C. Hoos
2001-10-29 1:42 ` Joseph Kwan
2001-10-29 13:35 ` Marc A. Criley
2001-10-25 12:48 ` Marc A. Criley
2001-10-25 12:54 ` sk
2001-10-25 15:41 ` Ted Dennison
2001-10-26 3:21 ` Smark [this message]
2001-10-26 5:45 ` James Rogers
2001-10-26 17:46 ` Smark
2001-10-26 14:30 ` Ted Dennison
2001-10-26 17:42 ` Smark
2001-10-26 20:02 ` Ted Dennison
2001-10-26 23:10 ` Jeffrey Carter
-- strict thread matches above, loose matches on Subject: below --
2001-10-29 18:16 Beard, Frank
2001-10-30 1:17 ` Adrian Hoe
2001-10-30 19:05 Beard, Frank
2001-10-31 4:10 ` Adrian Hoe
2001-10-31 19:40 Beard, Frank
2001-11-01 2:13 ` Adrian Hoe
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox