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,8a34575d5eb275cb X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!z14g2000yqa.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Load an object from a file Date: Sun, 19 Apr 2009 12:52:33 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <49d5fa88$0$2862$ba620e4c@news.skynet.be> <443d72ca-5bbd-46a3-84c6-e8bd984e5b80@k41g2000yqh.googlegroups.com> <49eb223e$0$2849$ba620e4c@news.skynet.be> NNTP-Posting-Host: 94.108.173.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1240170753 4680 127.0.0.1 (19 Apr 2009 19:52:33 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 19 Apr 2009 19:52:33 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: z14g2000yqa.googlegroups.com; posting-host=94.108.173.122; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.7) Gecko/2009030810 Iceweasel/3.0.7 (Debian-3.0.7-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:5511 Date: 2009-04-19T12:52:33-07:00 List-Id: Olivier Scalbert wrote on comp.lang.ada: > I have an endianness problem. In the file, The u2 data are stored in > big-endian order. As I am working on a Pentium, the reading is done in > little-endian order. Is it possible to fix it with the representation > stuff ? No; Ada's representation clauses only allow you to control bit order, not byte order. On little-endian architectures, you'll have to resort to something like procedure Read (Stream : access Ada.Streams.Root_Stream_Type'Class; Item : out u2) is type Byte is mod 2**8; for Byte'Size use 8; High_Order, Low_Order : Byte; begin Byte'Read (Stream, High_Order); -- call the predefined Read for type Byte Byte'Read (Stream, Low_Order); Item := High_Order * 2**8 + Low_Order; end Read; for u2'Read use Read; HTH -- Ludovic Brenta.