#PB_BIG_ENDIAN #PB_LITTLE_ENDIAN

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
WolfgangS
Enthusiast
Enthusiast
Posts: 174
Joined: Fri Apr 25, 2003 3:30 pm

#PB_BIG_ENDIAN #PB_LITTLE_ENDIAN

Post 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
WolfgangS' projects http://www.schliess.net
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
Fantoma
New User
New User
Posts: 6
Joined: Sun Jul 06, 2003 5:04 am
Location: Australia
Contact:

Post 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.
Post Reply