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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4c06e1e4fc2bf2d1 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Controlling endian-ness? Date: Tue, 12 Aug 2008 14:42:38 +0100 Organization: Pushface Message-ID: References: <4897b7f5$0$19705$4d3efbfe@news.sover.net> <4898d0ca$0$19680$4d3efbfe@news.sover.net> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1218548562 4260 62.49.19.209 (12 Aug 2008 13:42:42 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Tue, 12 Aug 2008 13:42:42 +0000 (UTC) Cancel-Lock: sha1:HadHIJebUWIB4jK7hapDC2hP0CY= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2.50 (darwin) Xref: g2news1.google.com comp.lang.ada:1604 Date: 2008-08-12T14:42:38+01:00 List-Id: "Peter C. Chapin" writes: > anon wrote: > >> For using Unsigned_32. Why not just override the built-in Write >> attributes routines for Unsigned_32 by re-writing the attributes >> routines. This may at most require a new package with a few extra >> attributes routines that may be needed. Also, this will also allow >> you to use "Shift_Left/Shift_Right" directly with Unsigned_32. >> >> So in your program you could use: >> >> Data : Unsigned_32 ; >> ... >> Unsigned_32'Write ( Stream_Pointer, Data ) ; > > I actually tried something like this but the compiler told me that I > couldn't redefine attributes for that type (or something like that). I > think the problem is that since the type is defined in another package > it is already frozen or some such. It could also be that I did it > wrong. (I'm not sure if this is in GNAT-GPL-2008, which I wasn't able to build for Intel Mac): (1) find s-strxdr.adb in the Ada library source directory .../adainclude/ (2) copy it to s-stratt.adb in your compilation path (3) give gnatmake the -a flag. s-strxdr.adb contains an alternate body for System.Stream_Attributes which streams to/from XDR (eXternal Data Representation) format. You might think you would only need to do this on the little-endian side, but there was a problem with Wide_Character in older GNATs (2 bytes or 4?) so checking the source would be good. Also, of course, you might have problems with floats: no problems found by us where it's IEE hardware both sides, eg PowerPC/i386.