From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: Stream_IO
Date: 1998/03/04
Date: 1998-03-04T00:00:00+00:00 [thread overview]
Message-ID: <34FD65CE.4D5E@gsfc.nasa.gov> (raw)
In-Reply-To: 34fcb5c5.33132164@SantaClara01.news.InterNex.Net
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
prev parent reply other threads:[~1998-03-04 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-03-04 0:00 Stream_IO Tom Moran
1998-03-04 0:00 ` Stream_IO John J. Cupak Jr.
1998-03-04 0:00 ` Stephen Leake [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox