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,b5cd7bf26d091c6f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!feeder.erje.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Reading the while standard input into a String Date: Wed, 8 Jun 2011 19:46:31 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <0fc4860c-6b14-493a-99a4-0b17e736ec48@glegroupsg2000goo.googlegroups.com> <959s61F40sU1@mid.individual.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1307580394 12378 69.95.181.76 (9 Jun 2011 00:46:34 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 9 Jun 2011 00:46:34 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6090 X-RFC2646: Format=Flowed; Response Xref: g2news2.google.com comp.lang.ada:20679 Date: 2011-06-08T19:46:31-05:00 List-Id: "Niklas Holsti" wrote in message news:959s61F40sU1@mid.individual.net... ... > The compiler can ignore pragma Pack in the sense that the compiler can > allocate memory for the data type in the same was as if there were no > pragma Pack. That is, the pragma does not have to result in a smaller > memory lay-out. The pragma only asks the compiler to *try* to minimize the > size, but the compiler does not have to try very hard... or at all. > > If you want to be sure that pragma Pack has some (desired) effect, you > should define the 'Size attribute of the type. If the compiler cannot pack > the type into the given size, it must report a compile-time error. In this particular case, where a specific representation of an array is desired, you have to specify 'Component_Size on the array type. Pack doesn't necessarily specify a particular representation, and even when it does, it is much better to explicitly state that you want 16 bit components (rather than just "smaller" components). In the original example, the type should have been declared: type Buffer is array (1..32) of Interfaces.Unsigned_16 with Component_Size => 16; presuming you have an Ada 2012 compiler. If not, fall back on those ugly attribute definition clauses: type Buffer is array (1..32) of Interfaces.Unsigned_16; for Buffer'Component_Size use 16; (Ugly because you have to repeat the type name and because they can get separated from the type.) Randy.