From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,d1fe9a910cd0ca57,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!postnews.google.com!i42g2000cwa.googlegroups.com!not-for-mail From: "Richard Charts" Newsgroups: comp.lang.ada Subject: Size of objects in records with an array. Date: 24 Oct 2006 10:48:58 -0700 Organization: http://groups.google.com Message-ID: <1161712138.465357.295460@i42g2000cwa.googlegroups.com> NNTP-Posting-Host: 12.129.98.129 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1161712144 2245 127.0.0.1 (24 Oct 2006 17:49:04 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 24 Oct 2006 17:49:04 +0000 (UTC) User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 S1PS Complaints-To: groups-abuse@google.com Injection-Info: i42g2000cwa.googlegroups.com; posting-host=12.129.98.129; posting-account=ydtQyAwAAAC1xxzVoGOYbHSW6zGrdJDV Xref: g2news2.google.com comp.lang.ada:7183 Date: 2006-10-24T10:48:58-07:00 List-Id: So I'm having more fun with records in Ada, particularly ones that must be of an exact form. I have a 32 bit data item I'd like to access the individual bits for. My initial way was the 1st blurb below. It works but reality slapped me in the face when I realized I needed to access the bits either like an array or with some way to loop through the bits. So I tried the bottom way, but it says the size is incorrect. Is there a way to make this work, or am I stuck looping and bit shifting a 32 bit item? Thanks. ------------------------------------------------- type Data_Msg is record A429 : Interfaces.Unsigned_8; Bit9 : Boolean; Bit10 : Boolean; Bit11 : Boolean; Bit12 : Boolean; Bit13 : Boolean; Bit14 : Boolean; Bit15 : Boolean; Bit16 : Boolean; Bit17 : Boolean; Bit18 : Boolean; Bit19 : Boolean; Bit20 : Boolean; Bit21 : Boolean; Bit22 : Boolean; Bit23 : Boolean; Bit24 : Boolean; Bit25 : Boolean; Bit26 : Boolean; Bit27 : Boolean; Bit28 : Boolean; Bit29 : Boolean; Bit30 : Boolean; Bit31 : Boolean; Bit32 : Boolean; end record; for Data_Msg use record A429 at 0 range 0..7; Bit9 at 1 range 0..0; Bit10 at 1 range 1..1; Bit11 at 1 range 2..2; Bit12 at 1 range 3..3; Bit13 at 1 range 4..4; Bit14 at 1 range 5..5; Bit15 at 1 range 6..6; Bit16 at 1 range 7..7; Bit17 at 2 range 0..0; Bit18 at 2 range 1..1; Bit19 at 2 range 2..2; Bit20 at 2 range 3..3; Bit21 at 2 range 4..4; Bit22 at 2 range 5..5; Bit23 at 2 range 6..6; Bit24 at 2 range 7..7; Bit25 at 3 range 0..0; Bit26 at 3 range 1..1; Bit27 at 3 range 2..2; Bit28 at 3 range 3..3; Bit29 at 3 range 4..4; Bit30 at 3 range 5..5; Bit31 at 3 range 6..6; Bit32 at 3 range 7..7; end record; for Data_Msg'size use (8 * 4); -------------------------------------------------- But I want to use this: -------------------------------------------------- type Bit_Array is array ( Natural range 8..31) of boolean; type Data_Msg is record A429 : Interfaces.Unsigned_8; Bit_Arr : Bit_Array := (others => false); end record; for Data_Msg use record A429 at 0 range 0..7; Bit_Arr at 1 range 0..23; end record; for Data_Msg'size use (8 * 4);