Page 1 of 1

#PB_BIG_ENDIAN #PB_LITTLE_ENDIAN

Posted: Sun Feb 20, 2005 5:55 pm
by WolfgangS
Hi,
I'm working on a sourcecode for a userlib. To make this sourceode compatible for future versions (the static lib is also available for MacOS X) I could need a kind of #PB_BIG_ENDIAN/#PB_LITTLE_ENDIAN constant ...

http://en.wikipedia.org/wiki/Little_endian

MFG
WolfgangS

Posted: Wed Feb 23, 2005 9:48 am
by Fantoma
I second that, i've just been using this sort of sloppy code to 'figure out' what endianness the compiler is meant to be using with constants.

Code: Select all

#ENDIAN_BIG.l         = $00000000  ; 68K, PPC
#ENDIAN_LITTLE.l      = $FFFFFFFF  ; x86

CompilerSelect #PB_Compiler_OS : 
  CompilerCase #OS_Amiga    :
    #ENDIAN.l                 = #ENDIAN_BIG
  CompilerCase #OS_Windows  :
    #ENDIAN.l                 = #ENDIAN_LITTLE
  CompilerCase #OS_Linux    :  ; Does Pure run on non-x86 cpus? I assume it doesnt
    #ENDIAN.l                 = #ENDIAN_LITTLE
  CompilerCase #OS_Mac      : 
    #ENDIAN.l                 = #ENDIAN_BIG
CompilerEndSelect
What would be handy is an extra qualifier on some commands like readlong() or peekl() to indicate the endianness of the source data. This would be handy for reading files or data from packets because it could 'convert' it automatically. I think its worthy of discussion in any case even if only a few people would ever use it.