Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sizeof in ADA

140 views
Skip to first unread message

sisi...@laposte.net

unread,
Aug 5, 2005, 10:42:41 AM8/5/05
to
I would like to know how to write an equivolent of the C function
"sizeof "
in Win32ADA to use with the GDI function " getobject " like this :

Buffer_Size:=Getobject(Mon_Bitmap,
Sizeof(Bitmap), -- this line obviously don't works
Buffer);

Lutz Donnerhacke

unread,
Aug 5, 2005, 10:57:36 AM8/5/05
to
* sisi...@laposte.net wrote:
> I would like to know how to write an equivolent of the C function "sizeof
> " in Win32ADA to use with the GDI function " getobject " like this :

'Size_in_Storage_Elements

Georg Bauhaus

unread,
Aug 5, 2005, 11:15:59 AM8/5/05
to


What is the Ada type of Bitmap?

from GetObject:

hObject ...
nCount int Secifies the number of bytes to be copied
to the buffer
lpObject ...

What do you want to copy?
The bitmap related structures in the Window API provide
information to compute the size of the bitmap in bytes
IIRC.

Marc A. Criley

unread,
Aug 5, 2005, 11:19:42 AM8/5/05
to
Lutz Donnerhacke wrote:
>
> 'Size_in_Storage_Elements

Did you mean 'Max_Size_In_Storage_Elements?

There's no Size_In_Storage_Elements attribute listed in either the RM or
amongst GNAT's implementation defined attributes.

-- Marc A. Criley
-- www.mckae.com
-- DTraq - XPath In Ada - XML EZ Out

cdm

unread,
Aug 5, 2005, 11:46:16 AM8/5/05
to
Ada 83 says X'SIZE returns the number of bits allocated to hold the
object.

Lutz Donnerhacke

unread,
Aug 5, 2005, 11:46:38 AM8/5/05
to
* Marc A. Criley wrote:
> Lutz Donnerhacke wrote:
>> 'Size_in_Storage_Elements
>
> Did you mean 'Max_Size_In_Storage_Elements?

Yes.

Jeffrey Carter

unread,
Aug 5, 2005, 12:00:04 PM8/5/05
to
sisi...@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

Martin Krischik

unread,
Aug 5, 2005, 1:16:57 PM8/5/05
to
0 new messages