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,d2fe923345e67606 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Byte sex confusion Date: 1997/05/11 Message-ID: #1/1 X-Deja-AN: 240950248 References: <33716475.43A9@top.monad.net> <33733B21.59E2B600@spam.innocon.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-05-11T00:00:00+00:00 List-Id: In article <33733B21.59E2B600@spam.innocon.com>, Jeff Carter wrote: >A simple solution is to convert everything into a standard >representation, and have portable conversion routines to and from that >representation. > >It is easy to: > >Use Unchecked_Conversion to convert your types into a type in Interfaces >that is unsigned and the same size as your type. [snip] Another way is to use Ada's built-in "change of representation" feature. A type and its derived type can have different representations, and type converting (no Unchecked_Conversion required) between the two types automatically converts the representation. This won't automatically byte-swap integers, though. Remember that some compilers support the 'Bit_Order attribute too, so that you can specify the layout of a record on a big-endian machine using a little-endian bit ordering, and vice versa. (Gee, I really wish GNAT supported that attribute. :-) -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271