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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,705f377a5e04a446 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!feeder.erje.net!aioe.org!not-for-mail From: Dennis Hoppe Newsgroups: comp.lang.ada Subject: Re: Bit operations in Ada (endianness) Date: Mon, 02 Jun 2008 15:27:32 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <87wslksmgk.fsf@ludovic-brenta.org> NNTP-Posting-Host: rfxIqsNOOcYSVIzBT0cW8Q.user.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org In-Reply-To: User-Agent: Thunderbird 2.0.0.14 (Macintosh/20080421) Xref: g2news1.google.com comp.lang.ada:516 Date: 2008-06-02T15:27:32+02:00 List-Id: 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 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).