
3 Oct
2005
3 Oct
'05
8:54 p.m.
On Mon, 3 Oct 2005, Joel Reymont wrote:
On Oct 3, 2005, at 6:51 AM, Marc Ziegert wrote:
data (Integral a) => BigEndian a = BigEndian a deriving (Eq,Ord,Enum,...) be = $( (1::CChar)/=(unsafePerformIO $ with (1::CInt) $ peekByteOff `flip` 0) ) :: Bool
Will this always correctly determine if the platform is big-endian? How does it actually work?
I don't know, having not used things like peekByteOff, but my suspicion would be that it's rather like, typedef char byte; char cChar = 1; int cInt = 1; int be = cChar != *(((byte*) &cInt) + 0); printf("be = %i\n", be); return 0; in C, so it's looking to see if the first byte of the int representation of 1 isn't 1. -- Mark