comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Byte sex confusion
Date: 1997/05/11
Date: 1997-05-11T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680001105971739370001@news.ni.net> (raw)
In-Reply-To: 33733B21.59E2B600@spam.innocon.com


In article <33733B21.59E2B600@spam.innocon.com>, Jeff Carter
<carter@spam.innocon.com> 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
<mailto:matthew_heaney@acm.org>
(818) 985-1271




      parent reply	other threads:[~1997-05-11  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-05-07  0:00 Byte sex confusion Steven O'Neill
1997-05-08  0:00 ` Nick Roberts
1997-05-09  0:00   ` Robert Dewar
1997-05-14  0:00     ` Steve Sciance
1997-05-09  0:00   ` Roy Grimm
1997-05-09  0:00 ` Jeff Carter
1997-05-10  0:00   ` Robert Dewar
1997-05-11  0:00   ` Oliver Kellogg
1997-05-11  0:00   ` Matthew Heaney [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox