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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,2203a21a136b39cc X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Fortran's Equivalence Date: 1997/04/08 Message-ID: #1/1 X-Deja-AN: 231689976 References: <333840D1.7B12@cae.ca> <3349165C.3B93@cae.ca> <1997Apr8.155111.26714@nosc.mil> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-04-08T00:00:00+00:00 List-Id: In article <1997Apr8.155111.26714@nosc.mil>, sampson@nosc.mil (Charles H. Sampson) wrote: >>record My_Record is >> A: some_type; >> B: some_other_type; >> C: still_another_type; >>end record; >>for My_Record_Type'Size use 32; >>for My_Record_Type use >> record >> A at 0 range 0 .. 14; >> B at 0 range 15 .. 24; >> C at 0 range 25 .. 31; >> end record; >> >>Does "range 0 .. 14" mean the Most Signicant Bits? Or does it mean >>"Left most bits"? This will clearly have an impact on my overlays. If >>I'm going to move bits arouund, then I don't want to have to change the >>record representation clauses... Will I be able to avoid it, by >>only changing my bit-manipulation routine, depending on my machine? > > The bit order depends on the compiler. If you want to do the ex- >tra work, you can code your record representation clauses to depend on >one or more constant objects which you then set to appropriate values >when transporting. True, "default" bit order depends on the compiler. But for a record representation clause, Ada 95 allows the programmer to specify how to interpret the bit order via the 'Bit_Order attribute definition clause. for My_Record_Type'Bit_Order use Low_Order_First; means that component A occupies the least significant portion of the 32 bits of storage. See RM95 13.5.3. Sadly, I don't think there's a way to specify order of array elements. For example, if I had a packed array of bits, I'd like the zero'th bit to always mean the bit located in the least significant bit of the storage. Right now, if I'm on a big endian machine, then bit 0 is the most significant. A bit of a pain, because I have to calculate the index of the array element I really want (O'Last - Index). I wish there were an attribute for arrays too, instead of just for records. Matt -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271