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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3939af2e1e61c8ee X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Stream_IO Date: 1998/03/04 Message-ID: <34FD65CE.4D5E@gsfc.nasa.gov>#1/1 X-Deja-AN: 330755627 Content-Transfer-Encoding: 7bit References: <34fcb5c5.33132164@SantaClara01.news.InterNex.Net> Content-Type: text/plain; charset=us-ascii Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Mime-Version: 1.0 Reply-To: Stephen.Leake@gsfc.nasa.gov Newsgroups: comp.lang.ada Date: 1998-03-04T00:00:00+00:00 List-Id: Tom Moran wrote: > > Is there a way to use Stream_IO to read a file produced by other than > the program doing the reading, in particular, a file binary file > produced, say, with C? The RM indicates the representation is > implementation defined, and 'read apparently quite ignores rep > clauses, so I find one compiler reads integer things of 'size 8 or 16 > as 16, and another reads size 16 things as size 32. I hate to read > into a String and then do Unchecked_Conversions or 'address overlays, > but I don't see any other portable approach. Help! I went around on this with Tucker Taft last fall, and the answer is: in general, you have to do unchecked conversion, and you have to live with the compiler differences. To make this (slightly) easier to swallow, consider trying to read a 12 bit integer from a stream. Since streams are defined in terms of memory words, if you are using an 8 or 16 bit word architecture, you will have to do some conversion to get 12 bits. The fact that some compilers read more than 8 bits for 8 bit integers from 8 bit streams is a consequence of the rules about base integer types; if the compiler chooses a 32 bit integer base type for an 8 bit integer type, it MUST read and write 32 bits from/to streams. This is an area that would benefit from uniformity guidelines, but it is not a simple issue, since it trades stream uniformity for arithmetic efficiency. -- - Stephe