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.6 required=5.0 tests=BAYES_00,LOTS_OF_MONEY, TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,79db4ff72bff9422 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-26 13:02:49 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <80d2e34.0110210156.7918cd3d@posting.google.com> <3bd402f9.8783319@news.demon.co.uk> <80d2e34.0110250340.155ae0b7@posting.google.com> <3BD7FE89.53BF8436@earthlink.net> <%oWB7.96$xS6.155@www.newsranger.com> Subject: Re: How to convert record? Message-ID: <6jjC7.1904$xS6.2897@www.newsranger.com> X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Fri, 26 Oct 2001 16:02:10 EDT Organization: http://www.newsranger.com Date: Fri, 26 Oct 2001 20:02:10 GMT Xref: archiver1.google.com comp.lang.ada:15278 Date: 2001-10-26T20:02:10+00:00 List-Id: In article , Smark says... > >"Ted Dennison" wrote in message >news:MreC7.1456$xS6.2002@www.newsranger.com... >> In article , Smark >says... >> > >> > >> >type Bubba_Type is record >> > C : Character; -- one byte >> > I : Integer; -- 4 bytes >> >end record; >> > >> >Bubba : Bubba_Type; >> > >> >Suppose that Integers must align on 4-byte boundaries. Then you might >> >get: >> > >> >Bubba_Type'Size = 40 (= 5 bytes) >> > >> >(Typename'size + System.Storage_Unit - 1) / System.Storage_Unit >> >= ( 40 + 8 - 1)/8 = 47/8 = 6 (bytes) >> > >> >But actually: >> > >> >Bubba'Size = 64 (= 8 bytes) >> >> I do not believe that is the case. If objects of this type are going to >> have holes in the middle for alignment purposes, then that should be >> reflected in the type's size. >> > >Try it out, or check out what the GNAT reference manual has to say about >GNAT's 'Object_Size attribute I did. I'm right. With Gnat on Win32, both Bubba_Type'size and Bubba'size are 64. The example in the UG has the fields reversed from your example. I'll give you that it does say that the type's 'size might be more than 7 bits smaller than the object's 'size. However, it does *not* say that it would return some kind of "packed" size for a type, where holes in the *middle* of a record are ignored, as you seem to be implying. I do not believe an Ada compiler is allowed to do this. >(don't you suppose there is a reason that GNAT added this attribute?). I thought it was so that you didn't have to have an object hanging around to take a 'size on to get an exact size. As a matter of fact, I still think that. :-) --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html No trees were killed in the sending of this message. However a large number of electrons were terribly inconvenienced.