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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ebc19d379b37caae X-Google-Attributes: gid103376,public From: "Stanley R. Allen" Subject: Re: Type size vs. actual size difference. Date: 2000/03/20 Message-ID: <38D666EC.AB575A49@raytheon.com>#1/1 X-Deja-AN: 600020474 Content-Transfer-Encoding: 7bit References: <8b5hhp$pvv1@svlss.lmms.lmco.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: NASA, Kennedy Space Center Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-03-20T00:00:00+00:00 List-Id: Bruce Detter wrote: > > Using GNAT 3.12 on Win NT 4.0. We have defined a record that has a length > of 214 bytes. The type'Size attribute reports 214, but when we declare a > variable of the record type (X : Type) the size attribute X'Size reports > 216. It appears the actual variable size takes into account adjustments to > word boundaries (and of course the type'Size attribute can't do this). Is > there a preprocessor command or pragma command that will force byte boundary > alignment so that the type size agrees with the actual size? > I don't think there is a standard way to do this. On GNAT, there is an attribute T'Object_Size, which when applied to types will yield the number of bits that would be used for a variable if declared "A : T;". On the old DEC Ada compiler, you could use the attribute T'Machine_Size, which would do the same thing. I don't know about other compilers. It would be nice if something like T'Object_Size was standard. In some cases it's necessary for me to declare a 'dummy' variable of a type to get this. -- Stanley Allen mailto:Stanley_R_Allen@raytheon.com