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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,bb6f4bd169077fb3,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-02-07 06:15:19 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: dallex@erols.com (Daniel Allex) Newsgroups: comp.lang.ada Subject: Representing data differently Date: 7 Feb 2003 06:15:18 -0800 Organization: http://groups.google.com/ Message-ID: <686be06c.0302070615.3943b629@posting.google.com> NNTP-Posting-Host: 208.19.133.132 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1044627318 16961 127.0.0.1 (7 Feb 2003 14:15:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 7 Feb 2003 14:15:18 GMT Xref: archiver1.google.com comp.lang.ada:33879 Date: 2003-02-07T14:15:18+00:00 List-Id: In C I can represent the same data multiple ways using structs and unions. How and can I do this in Ada? See example below: // // Example of C's representation clause // #include #define mt37_length 4 enum BOOL {FALSE, TRUE}; struct MT_37_header { short :4, nw:6, mt:6; short :16; // place holder short :16; // place holder short :16; // place holder }; struct MT_37_fields { short :1, // not used :1, // spare surv:1, kill:1, :6, // filler :6; // filler short ctsl; short :1, // not used :4, // spare gaff:1, smid:5, weapon_type:3, sif:1, dest:1; short ctsl_msl; }; struct bool_fields { short b0:1,b1:1,b2:1,b3:1,b4:1,b5:1,b6:1,b7:1,b8:1, b9:1,b10:1,b11:1,b12:1,b13:1,b14:1,b15:1; }; struct MT_37_bools { struct bool_fields wd[mt37_length]; }; struct MT_37_words { short wd0; short wd1; short wd2; short wd3; }; struct MT_37_message { short msg[mt37_length]; }; union MT_37 { struct MT_37_header header; struct MT_37_message message; struct MT_37_fields fields; struct MT_37_words words; struct MT_37_bools bools; }; typedef union MT_37 MT_37; void main() { MT_37 mt37; mt37.header.nw = 3; mt37.header.mt = 037; mt37.fields.surv = TRUE; mt37.fields.kill = TRUE; mt37.fields.ctsl = 022; mt37.fields.gaff = TRUE; mt37.fields.smid = 01; mt37.fields.weapon_type = 03; mt37.fields.sif = TRUE; mt37.fields.dest = FALSE; mt37.fields.ctsl_msl = 0102; for(int i=0; i