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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a415d3a613d86a4e X-Google-Attributes: gid103376,public From: Mats Weber Subject: GNAT'Object_Size Date: 1997/12/04 Message-ID: <3486E304.E595675C@elca-matrix.ch>#1/1 X-Deja-AN: 295401735 References: <662cs9$b34$1@newman.pcisys.net> <663j9f$e1l@mtinsc02.worldnet.att.net> <3485D2AE.3F54@hso.link.com> Reply-To: Mats.Weber@elca-matrix.ch Organization: ELCA Matrix SA Newsgroups: comp.lang.ada Date: 1997-12-04T00:00:00+00:00 List-Id: Stanley R. Allen wrote: > While we are on the subject, it would be nice if the GNAT-defined > 'Object_Size (a better name than the equivalent DEC-Ada-defined > 'Machine_Size) attribute was universally adopted as well. Those > of us who must work at the bit level get frustrated when we cannot > get at the actual number of bits that will be allocated for an > entity, rather than the "minumum" given by 'Size. And also generalize 'Object_Size so that it works on objects as well as types, and returns the size actually allocated for an object, so that the following code can be made to work: generic type T (<>) is private; procedure Receive (M : out T) is function Read (FD : Integer; Buffer : System.Address; Count : Integer) return Integer; pragma Import(C, Read); Length : Integer; begin Length := Read(Socket, M'Address, M'Object_Size / System.Storage_Unit); end; Using 'Size in this situation is not portable because some compilers take it to mean the size of the current value, not that of the object (which can be different in the case of unconstrained types).