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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,f25e636d6b770960 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-27 18:24:58 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!sn-xit-01!supernews.com!207.217.77.43.MISMATCH!newsfeed1.earthlink.net!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.prod.itd.earthlink.net.POSTED!not-for-mail From: "Eric G. Miller" Subject: Re: Last stream problem: byte order Newsgroups: comp.lang.ada Message-ID: References: <3CA04CA6.338B37D7@ib-paus.com> <3CA20BAA.FD53C08A@ib-paus.com> User-Agent: Pan/0.11.2 (Unix) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Comment-To: "Dr. Michael Paus" Date: Thu, 28 Mar 2002 02:24:57 GMT NNTP-Posting-Host: 216.119.28.246 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.prod.itd.earthlink.net 1017282297 216.119.28.246 (Wed, 27 Mar 2002 18:24:57 PST) NNTP-Posting-Date: Wed, 27 Mar 2002 18:24:57 PST Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:21740 Date: 2002-03-28T02:24:57+00:00 List-Id: In <3CA20BAA.FD53C08A@ib-paus.com>, Dr. Michael Paus wrote: > Erik Sigra schrieb: >> >> tisdagen den 26 mars 2002 11.25 skrev du: >> > If you also check the byte order of your system at runtime (there is a >> > system constant in Ada which you can check) you can even achieve the effect >> > that all stream data is always written in network byte order independent of >> > the platform your program is running on. >> >> Why runtime check? Compile time check seems more reasonable to me. Or can the >> same compiled program really run on architectures with different endiannes? > > It depends on how clever the compiler is. If the compiler optimizes the > static expression in the following if-statement away then it is indeed a > compile time check. Otherwise it is a run-time check. > > if System.Default_Bit_Order = System.Low_Order_First then > ... (swap the bytes) > else > ... (don't swap the bytes) > end if; > > But I don't think this makes a big difference in either case. GNAT gives a warning that the condition is always true (or false). Don't know if it eliminates the unreachable branch (I would think so with -02). Resorting to preprocessing trickery would probably insure it is always a compile time check. Don't know if there's another way...