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!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "(see below)" Newsgroups: comp.lang.ada Subject: Re: Bit operations in Ada (endianness) Date: Mon, 02 Jun 2008 15:01:19 +0100 Message-ID: References: <87wslksmgk.fsf@ludovic-brenta.org> Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: individual.net kvH/GHMjVx/g0zMMA1B7Wwe39ZAAihk/xtK57y36AQoAW6KSgd Cancel-Lock: sha1:9S5XO0QK/rrFBO+Kx0EMq7Y6jr8= User-Agent: Microsoft-Entourage/12.10.0.080409 Thread-Topic: Bit operations in Ada (endianness) Thread-Index: AcjEuSF+ZkBq1jH8906U1VH7I2qrdQ== Xref: g2news1.google.com comp.lang.ada:519 Date: 2008-06-02T15:01:19+01:00 List-Id: On 02/06/2008 14:27, in article g20sg4$nkb$1@aioe.org, "Dennis Hoppe" wrote: > I also wonder, if I can query the operating system via Ada, > which endianness it uses. No need to talk to the OS. Try something like this: -- N.B. not tested as written! not_little_endian : exception; type i08 is mod 2**8; type i64 is mod 2**64; type i08_group is array (0..7) of i08; for i08_group'Component_Size use 8; for i08_group'Size use 64; the_i64 : i64 := 0; the_i08_group : i08_group; for the_i08_group'Address use the_i64'Address; pragma Import (Ada, the_i08_group); -- the_i08_group(0) := 1; if the_i64 /= 1 then raise not_little_endian end if; -- Bill Findlay chez blueyonder.co.uk