comp.lang.ada
 help / color / mirror / Atom feed
From: Christoph Grein <christoph.grein@eurocopter.com>
Subject: Re: Confused about Attribute Size?
Date: Tue, 22 Jan 2002 09:00:43 +0100 (MET)
Date: 2002-01-22T09:00:43+01:00	[thread overview]
Message-ID: <mailman.1011686522.29401.comp.lang.ada@ada.eu.org> (raw)

> 
> type My_Type is
>     (startbit,
>      endbit,
>      timeout,
>      spare,
>      nextbit,
>      ......
>      ......
>      lastbit);

This assigns _values_ (not bit positions) to the enumeration literals that shall 
be used to represent them internally, i.e. startbit has the value (or is another 
name for) 0, lastbit the value 15. However you have no access to the internal 
values (you can't add them e.g. startbit + timeout is illegal).

> for My_Type use
>     (startbit =>0,
>      endbit=>1,
>      timeout=>2,
>      spare=>3,
>      nextbit=>4,
>      ......
>      ......
>      lastbit=>15);
> 
> for My_Type'Size use 8;

Since a value of 15 = 2#00001111# can be represented in 8 bits, there is no 
problem.

> 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?

In Ada95, there is no need to explicitly define this default representation, see 
RM 13.4(8).



             reply	other threads:[~2002-01-22  8:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-22  8:00 Christoph Grein [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-01-22  7:39 Confused about Attribute Size? Zebylon
2002-01-22 19:08 ` Patrick Hohmeyer
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
replies disabled

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