streams on PPC

Archives Forums/MacOS X Discussion/streams on PPC

Jur(Posted 2009) [#1]
I got informed of a problem on (some?) G4 systems. I found out that the stream reading doesnt work as it should. The first reading of a stream - stream.ReadInt() doesn´t return the right number.
Are there any known issues when it comes to stream reading in correlation with language or anything system related?


Floyd(Posted 2009) [#2]
Here's something I posted in another thread about streams:


BlitzMax defaults to the endianness your CPU uses, LittleEndian for Intel and BigEndian for PowerPC. You can specify which one to use.

testfile$ = "data_12345678.bin"


TS:TStream = WriteStream( testfile ) 
WriteInt( TS, $12345678 )
CloseStream TS

TS = ReadStream( testfile )
DefaultEndian = ReadInt( TS )
CloseStream TS

TS = BigEndianStream( ReadStream( testfile ) )
BigEndian = ReadInt( TS )
CloseStream TS

TS = LittleEndianStream( ReadStream( testfile ) )
LittleEndian = ReadInt( TS )
CloseStream TS

DeleteFile testfile

Print
Print " Test endianness:"
Print
Print " Default " + Hex( DefaultEndian )
Print "  Little " + Hex( LittleEndian )
Print "     Big " + Hex( BigEndian )



Jur(Posted 2009) [#3]
Thanks. That explains the problem. I will have to convert streams to LittleEndian on mac.