MemoryBlock.LittleEndian Docs Confusion

Regarding the LittleEndian property of a MemoryBlock. The Xojo docs state:

Sets the endianness of a MemoryBlock . The default is the endianness of the platform on which the code is being compiled.

Immediately beneath this, the beginning of the example code states:

Var mb1 As New MemoryBlock(2) // defaults to Little Endian = True on all platforms

Does anyone know which of the two it is? Do MemoryBlocks default to the platform’s endianness or True?

1 Like

IIRC All the currently supported platforms have teh same endianness, which is why that comment.

they default to little endian as far as I can tell since they are ALL intel based :slight_smile:
that behaved differently when there was PPC targets as well

1 Like

What about RPI/ARM?

Well ARM is a bit screwy
You can actually run it either way :slight_smile:
Or you can use it mixed where the supervisor is big endian and apps are little
Cant say I have ever run into that

But by default ARM is little endian
The easiest way to tell is to create a MB with 2 bytes
Then stuff in the value &FFEE
And examine each byte independently
If byte 0 is EE and byte 1 FF you’re little endian
If they are reversed its big endian

I wrote code on my old downloads page to tell this when it used to be much more relevant
http://great-white-software.com/gws-rb-samples/Endianess.zip

Updated a version that opens without any messing about so if you download that you can just drag it into a project and use it
That code is 16 years old :slight_smile:

edit - changed “I’ll update” to “updated”

Ok, so what’s the correct answer to Garry’s question then?

All intel platforms are little endian
All iOS platforms are little endian
As far as my experience goes Pi’s are all little endian (but could be either)

But in that case will memoryblocks be created with the right endianness in all situations by default (I don’t do Pi so I don’t know the behavior there).

I have written generic code that gets relies on that.

-Karen
-Karen

It should create it in the correct mode (as documented)
If it doesnt its a bug

And you CAN check with the code I posted

My Pi is a bit fubar at the moment so I cant check

I guess may point is that we should be careful of marking questions as solved if we don’t know the answer absolutely.

There IS no “absolute answer” to the Pi question as that will depend on what OS and mode it running in - so the answer for that is “it depends”

And you can determine the endianness at runtime and deal with it

Then that’s what the answer should be. That’s my point. I think it’s important that forums try to promote correct answers, otherwise they’re no better than facebook groups!