From: Dennis Hoppe <dennis.hoppe@hoppinet.de>
Subject: Re: Bit operations in Ada (endianness)
Date: Mon, 02 Jun 2008 15:27:32 +0200
Date: 2008-06-02T15:27:32+02:00 [thread overview]
Message-ID: <g20sg4$nkb$1@aioe.org> (raw)
In-Reply-To:
Hi,
I have another question regarding litte and big-endian. Is there
any way to declare, that the type
type Bit_Field is array (Bit_Number) of Boolean;
is represented by litte or big-endian? Bit_Number is a generic
paremeter (mod <>). I figured out to set the endianness to
record types, but it does not work for the above array type.
I also wonder, if I can query the operating system via Ada,
which endianness it uses.
Thank you in advance,
Dennis Hoppe
Simon Wright wrote:
> Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>
>> Another alternative is Unchecked_Conversion:
>>
>> type Bit_Number is range 0 .. 31;
>> type Bit_Field is array (Bit_Number) of Boolean;
>> pragma Pack (Bit_Field);
>> function To_Bit_Field is
>> new Ada.Unchecked_Conversion (Source => Interfaces.Unsigned_32,
>> Target => Bit_Field);
>
> Whether this does what you want may depend on whether the machine is
> big-endian (eg, SPARC, PowerPC etc) or not (Intel etc).
next prev parent reply other threads:[~2008-06-02 13:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-23 21:19 Bit operations in Ada Dennis Hoppe
2008-05-23 22:08 ` Ludovic Brenta
2008-05-24 15:36 ` Simon Wright
2008-06-02 13:27 ` Dennis Hoppe [this message]
2008-06-02 14:01 ` Bit operations in Ada (endianness) (see below)
2008-06-02 18:22 ` Jeffrey R. Carter
2008-06-02 17:38 ` Ludovic Brenta
2008-05-23 22:38 ` Bit operations in Ada Robert A Duff
2008-05-24 0:27 ` Randy Brukardt
2008-05-24 9:40 ` Bit operations in Ada (Thank you) Dennis Hoppe
2008-05-23 23:25 ` Bit operations in Ada Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox