comp.lang.ada
 help / color / mirror / Atom feed
From: wdl39!mab@ford-wdl1.arpa  (Mark A Biggar)
Subject: Re: Declaring Arrays of Bits (how)?
Date: 29 Sep 92 17:07:54 GMT	[thread overview]
Message-ID: <1992Sep29.170754.4140@wdl.loral.com> (raw)

In article <YOUNG.92Sep29101112@kuwait.gdfwc3> young@gdfwc3 (Mark Young) writes
:
>I am trying to declare arrays of bits in Ada.  Here's my attempt:
>type Array_Range_Type is range 1..128;
>type Bit_Type is (OFF, ON);
>for  Bit_Type use (OFF => 0, ON => 1);
>for  Bit_Type'size use 1;
>type Bit_Array_Type is array (Array_Range_Type) of Bit_Type;
>Bit_Array : Bit_Array_Type;
>
>This looks right to me.  I would expect Bit_Array to be represented
>as an array of 128 bits (128 contiguous bits).  This is not the case,
>however.  My compiler (XDADA) is representing Bit_Array as an array
>of 128 bytes.  As an added note, I have been using representation clauses
>for records without any problems.  
>Am I missing something?  
>Is there a special representation clause for arrays that I am overlooking? 
>Is my compiler at fault?

For most compilers you probably need to throw a:

pragma PACKED(Bit_Array_Type);

in the mix somewhere as well.  Otherwise according to the LRM the compiler is
under no obligation to put the array element in anything smaller then a byte
each unless you add the pragma PACKED.

--
Mark Biggar
mab@wdl1.wdl.loral.com

             reply	other threads:[~1992-09-29 17:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-09-29 17:07 Mark A Biggar [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-09-29 18:33 Declaring Arrays of Bits (how)? Bob Kitzberger
1992-09-29 16:54 jvnc.net!darwin.sura.net!jhunix.hcf.jhu.edu!aplcen.apl.jhu.edu!ddsdx2.jhu
1992-09-29 16:11 agate!spool.mu.edu!sdd.hp.com!cs.utexas.edu!sun-barr!west.West.Sun.COM!cr
replies disabled

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