comp.lang.ada
 help / color / mirror / Atom feed
From: Patrick Hohmeyer <pi3_1415926536@yahoo.ca>
Subject: Re: Confused about Attribute Size?
Date: Tue, 22 Jan 2002 14:08:41 -0500
Date: 2002-01-22T14:08:41-05:00	[thread overview]
Message-ID: <Mni38.4031$Ii5.1732203@news20.bellglobal.com> (raw)
In-Reply-To: a2j3lh$5nt$1@newstoo.ericsson.se

And Zebylon has spoken :

> Hi,
> 
> I'm a newbie in Ada but I saw an Ada example that confused me a bit, here
> it is:
> 
> type My_Type is
>     (startbit,
>      endbit,
>      timeout,
>      spare,
>      nextbit,
>      ......
>      ......
>      lastbit);
> 
> for My_Type use
>     (startbit =>0,
>      endbit=>1,
>      timeout=>2,
>      spare=>3,
>      nextbit=>4,
>      ......
>      ......
>      lastbit=>15);
> 
> for My_Type'Size use 8;
> 
> type My_Type_Array is array (My_Type) of Boolean;
> 
> What I don't understand is how you can assign the size to 8 bits? How will
> this work when
> there are 16 bits in the type? What will be the size of the array?
> This example was in Ada 83 could this be a clue?
> 
> Thanks
> 
> /S

Hint : My_Type is an enumeration type.

Ex : Character is also an enumeration,
there are 256 possible characters,
does this make a character 256 bit ? ;-)

The array will be 16 or 2 bytes
(if you use the pragma pack, what I suspect)
One boolean per possible value of My_Type.

Hint2 : try some general tutorials befor trying to understand chapter 13.

-- 
Patrick Hohmeyer



  reply	other threads:[~2002-01-22 19:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-22  7:39 Confused about Attribute Size? Zebylon
2002-01-22 19:08 ` Patrick Hohmeyer [this message]
2002-01-22 22:56 ` Mark Johnson
2002-01-23  2:20   ` Jeffrey Carter
2002-01-23 14:56     ` Mark Johnson
2002-01-23 17:06       ` Jeffrey Carter
2002-01-24  4:11         ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
2002-01-22  8:00 Christoph Grein
replies disabled

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