comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam@spam.com>
Subject: Re: shifting bits
Date: Mon, 30 Aug 2004 18:48:29 GMT
Date: 2004-08-30T18:48:29+00:00	[thread overview]
Message-ID: <1EKYc.2879$w%6.1846@newsread1.news.pas.earthlink.net> (raw)
In-Reply-To: <cgvnfq$9ro$1@a1-hrz.uni-duisburg.de>

Georg Bauhaus wrote:

> when I declare
> 
>    type month_type is range 1 .. 12;
>    for month_type'Size use 4;
> 
>    m: month_type := 1;
> 
> the compiler chooses 8 (following the rule
> "Object_Size must be 8, 16, 32, or multiple of 64"
> I guess.)
> 
>    TIO.put_line("m's size: " & Natural'image(m'size));
> 
> prints
> 
> m's size:  8

A specified 'Size effects the size in a packed composite type, but not 
for a stand-alone object. Try

type Month_List is array (Month_Type) of Month_Type;
pragma Pack (Month_List);

L : Month_List;

TIO.Put_Line ("L's size: " & Natural'image (L'Size) );

GNAT 3.15p/Win98 outputs

M's size:  8
L's size:  64

L has been padded to a multiple of 32, which is allowed because it's a 
stand-alone object, but is not 96, which is what you would get if each 
component were 8 bits.

-- 
Jeff Carter
"Now look, Col. Batguano, if that really is your name."
Dr. Strangelove
31




  reply	other threads:[~2004-08-30 18:48 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-29  1:38 shifting bits fabio de francesco
2004-08-29  3:51 ` Jim Rogers
2004-08-29  6:51   ` Martin Krischik
2004-08-29 12:53   ` fabio de francesco
2004-08-29 13:21     ` Ludovic Brenta
2004-08-29 17:58       ` Simon Wright
2004-08-29 14:25     ` Michael Bode
2004-08-29 11:29 ` Ludovic Brenta
2004-08-29 17:17   ` tmoran
2004-08-29 13:53 ` Stephen Leake
2004-08-29 17:17 ` tmoran
2004-08-30  3:49   ` fabio de francesco
2004-08-30  4:16     ` tmoran
2004-08-31  0:22       ` fabio de francesco
2004-10-10 17:51     ` ACM Queue Ada article tmoran
2004-10-11 13:13       ` Marc A. Criley
2004-10-12 18:32         ` skidmarks
2004-11-30 18:04     ` SIGAda ad tmoran
2005-05-25  7:19     ` Gnat STORAGE_ERROR tmoran
2005-05-25  8:53       ` Alex R. Mosteo
2005-05-25  9:51         ` Duncan Sands
2005-05-25 10:05           ` Alex R. Mosteo
2005-05-25 11:32             ` Duncan Sands
2005-05-25 12:16               ` Alex R. Mosteo
2005-05-26  9:39                 ` Duncan Sands
2005-05-26  9:53                   ` Alex R. Mosteo
2005-05-26 19:32                   ` Björn Persson
2005-05-25 18:30         ` tmoran
2005-05-26  2:19           ` David C. Hoos, Sr.
2005-05-26 18:42             ` tmoran
2005-05-27  7:19               ` workaround, was " tmoran
2005-07-29 21:08     ` shifting bits tmoran
2005-07-30 20:28     ` Ada utility for Google Earth, NASA World Wind tmoran
2005-08-08 13:27       ` Marc A. Criley
2005-08-08 21:08         ` tmoran
2005-08-10  8:11         ` Rob Norris
2005-08-10  8:35           ` tmoran
2005-08-10 11:41             ` Rob Norris
2005-08-10 18:05               ` tmoran
2004-08-30  9:03 ` shifting bits Ole-Hjalmar Kristensen
2004-08-30 11:37   ` Dale Stanbrough
2004-08-30 18:38     ` Jeffrey Carter
2004-08-30 15:19 ` Martin Krischik
2004-08-30 17:17   ` Georg Bauhaus
2004-08-30 18:48     ` Jeffrey Carter [this message]
2004-08-31 12:37       ` Georg Bauhaus
replies disabled

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