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=3.8 required=5.0 tests=BAYES_00,INVALID_MSGID, RATWARE_MS_HASH,RATWARE_OUTLOOK_NONAME 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: "Nick Roberts" Subject: Re: FORTRAN's Equivalence Date: 1997/03/26 Message-ID: <01bc3a3b$ad32cb80$63f482c1@xhv46.dial.pipex.com>#1/1 X-Deja-AN: 228659748 References: <333840D1.7B12@cae.ca> Organization: UUNet PIPEX server (post doesn't reflect views of UUNet PIPEX) Newsgroups: comp.lang.ada Date: 1997-03-26T00:00:00+00:00 List-Id: Viqar Abbasi wrote in article <333840D1.7B12@cae.ca>... > 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. Robert Duff (circa this thread) is right, in that you should use the for X'Address clause preferred in Ada 95. > 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? You should not use Unchecked_Conversion, you should use the method you suggested above. Don't worry about whether the technique you use is portable or not. It will not be, and does not need to be. All you need to do is to ISOLATE the non-portable bit (in a subprogram or package). Ensure that the interface to this module is well defined. Then, all you have to do to port to a new compiler or target is to change the isolated module. Everything else remains untouched, and (provided the tenets of the interface are not violated) its operation remains guaranteed. > Furthermore, are any of you aware of a better way to map variables on > top of each other? Please consider in any reply that I have extremely > tight speed requirements as well. Why do you need to do this? There may well be a better way to achieve whatever you need to do. Hope this helps. Nick.