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/03/29 Message-ID: #1/1 X-Deja-AN: 229336727 References: <333840D1.7B12@cae.ca> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-03-29T00:00:00+00:00 List-Id: In article <333840D1.7B12@cae.ca>, Viqar Abbasi wrote: >I have a BIT_PATTERN : System.Unsigned_32. The first 4 bits represent >an integer A, the next 17 represent another record B, the last eleven >represent an integer C. Ada gives something beautiful, in the "use at" >clause, which lets me define a record to superimpose onto the bit >pattern. The big problem with this approach is that it isn't >guaranteed by the LRM, and I need my application to be portable to >other Ada implementations. The Ada Quality and Style Guide, Clause >5.9.4, also tells us that we should not use the "use at" clause to do >such things. I am using the GNAT compiler, 3.07 on the SGI. The final >system will be delivered for a VAX. > >I have started doing my mapping via "Unchecked Conversions". This seems >to be going well, as long as I take care of the VAX/SGI bit-pattern >differences. Would using Unchecked_Conversions, when the sizes are >always the same, be considered 100% portable, and will work under any >ADA implementation? Why wouldn't it be portable? RM95 13.9 (5 - 10) list the conditions under which the language guarantees the behavior of Unchecked_Conversion. Since your target type is constrained, and the size of the source and target types are the same, what's non-portable about UC? The words about the RM recommending to not use "use at" may be referring to the fact that that form of address overlay clause is an obsolescent feature of the language; it was replaced by the O'Address form. Of course, you shouldn't be using address overlays to change representation anyway, and the RM is rightly admonishing you to not do so. That what Unchecked_Conversion is for. To move data - portably - from a big-endien to a little endien machine, be sure to use the Bit_Order attribute described in RM95 13.5.3. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271