From: Jeffrey Carter <spam@spam.com>
Subject: Re: sizeof in ADA
Date: Fri, 05 Aug 2005 09:00:04 -0700
Date: 2005-08-05T09:00:04-07:00 [thread overview]
Message-ID: <82MIe.7$dG.4@dfw-service2.ext.ray.com> (raw)
In-Reply-To: <1123252961.173046.299550@o13g2000cwo.googlegroups.com>
sisi.ard@laposte.net wrote:
> I would like to know how to write an equivolent of the C function
> "sizeof "
There is the 'Max_Size_In_Storage_Units attribute, which may be what you
want.
The 'Size attribute gives the size in bits of a subtype or object. For a
stand-alone object, 'Size is usually a multiple of System.Storage_Unit,
which is the number of bits in a storage unit (8 on a byte-oriented
processor).
Note that 'Size can differ between a subtype and an object. For many
platforms and compilers:
Boolean'Size = 1
Natural'Size = 31
B : Boolean;
N : Natural;
B'Size = 8;
N'Size = 32
So Object'Size / System.Storage_Unit will give you the correct value for
an object. It may be better to base your values on the object than on
the subtype.
Another way is to instantiate Ada.Storage_IO for the subtype. This then
gives you the constant Buffer_Size, which is what you want. This is
rather a heavyweight solution, however.
--
Jeffrey Carter
"Now go away or I shall taunt you a second time."
Monty Python and the Holy Grail
E-mail: jeffrey_r_carter-nr [commercial-at]
raytheon [period | full stop] com
next prev parent reply other threads:[~2005-08-05 16:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-08-05 14:42 sizeof in ADA sisi.ard
2005-08-05 14:57 ` Lutz Donnerhacke
2005-08-05 15:19 ` Marc A. Criley
2005-08-05 15:46 ` Lutz Donnerhacke
2005-08-05 15:15 ` Georg Bauhaus
2005-08-05 15:46 ` cdm
2005-08-05 16:00 ` Jeffrey Carter [this message]
2005-08-05 17:16 ` Martin Krischik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox