comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Reading the while standard input into a String
Date: Wed, 8 Jun 2011 19:46:31 -0500
Date: 2011-06-08T19:46:31-05:00	[thread overview]
Message-ID: <isp559$c2q$1@munin.nbi.dk> (raw)
In-Reply-To: 959s61F40sU1@mid.individual.net

"Niklas Holsti" <niklas.holsti@tidorum.invalid> 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.






  reply	other threads:[~2011-06-09  0:46 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-05 16:20 Reading the while standard input into a String Natasha Kerensikova
2011-06-06  1:49 ` robin
2011-06-06  7:18 ` Dmitry A. Kazakov
2011-06-06 10:46   ` Natasha Kerensikova
2011-06-06 12:05     ` Dmitry A. Kazakov
2011-06-06 16:55       ` Jeffrey Carter
2011-06-06 17:42         ` Pascal Obry
2011-06-06 17:43         ` Pascal Obry
2011-06-06 18:31         ` Dmitry A. Kazakov
2011-06-06  8:09 ` stefan-lucks
2011-06-06  8:33 ` Ludovic Brenta
2011-06-06 10:08   ` Natasha Kerensikova
2011-06-06 10:27     ` Ludovic Brenta
2011-06-06 10:31       ` Ludovic Brenta
2011-06-06 12:07         ` Natasha Kerensikova
2011-06-06 15:18   ` Maciej Sobczak
2011-06-06 18:18     ` Dmitry A. Kazakov
2011-06-06 18:36       ` Maciej Sobczak
2011-06-06 18:53         ` Dmitry A. Kazakov
2011-06-06 19:10           ` J-P. Rosen
2011-06-06 19:46             ` Dmitry A. Kazakov
2011-06-06 23:37           ` Shark8
2011-06-07  3:00             ` Randy Brukardt
2011-06-07  7:25             ` Dmitry A. Kazakov
2011-06-07  7:32           ` Maciej Sobczak
2011-06-07  8:51             ` Dmitry A. Kazakov
2011-06-07  3:10         ` Randy Brukardt
2011-06-06 19:06       ` J-P. Rosen
2011-06-06 19:52         ` Dmitry A. Kazakov
2011-06-07  3:15         ` Randy Brukardt
2011-06-06 22:14   ` Robert A Duff
2011-06-06  9:46 ` Georg Bauhaus
2011-06-06 11:16 ` Georg Bauhaus
2011-06-06 12:11   ` Dmitry A. Kazakov
2011-06-06 13:32     ` Georg Bauhaus
2011-06-06 14:06       ` Dmitry A. Kazakov
2011-06-06 14:14         ` Georg Bauhaus
2011-06-07  3:19         ` Randy Brukardt
2011-06-06 18:14 ` John B. Matthews
2011-06-07 10:23   ` Martin
2011-06-07 16:57     ` John B. Matthews
2011-06-07 17:22     ` Robert A Duff
2011-06-07 17:55       ` John B. Matthews
2011-06-08  0:26         ` Robert A Duff
2011-06-08  7:38         ` Egil Høvik
2011-06-08  9:27           ` Martin
2011-06-08 12:04             ` Egil Høvik
2011-06-08 18:09               ` Niklas Holsti
2011-06-09  0:46                 ` Randy Brukardt [this message]
2011-06-10  8:22                   ` Martin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox