From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bb020506b8efd1bb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bos-service1.raytheon.com!dfw-service2.ext.ray.com.POSTED!53ab2750!not-for-mail From: Jeffrey Carter User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: sizeof in ADA References: <1123252961.173046.299550@o13g2000cwo.googlegroups.com> In-Reply-To: <1123252961.173046.299550@o13g2000cwo.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <82MIe.7$dG.4@dfw-service2.ext.ray.com> Date: Fri, 05 Aug 2005 09:00:04 -0700 NNTP-Posting-Host: 147.24.111.90 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.ray.com 1123257604 147.24.111.90 (Fri, 05 Aug 2005 11:00:04 CDT) NNTP-Posting-Date: Fri, 05 Aug 2005 11:00:04 CDT Organization: Raytheon Company Xref: g2news1.google.com comp.lang.ada:3983 Date: 2005-08-05T09:00:04-07:00 List-Id: 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