A list of var types with endianness - operating system ?

I'm looking for a list in which I can see var types and the endianness used clasiffied by operating system and /or processor.
Any link ?

Can I use a specific kind of var type endianness independent ?

Thanks
Last edited on
Endianness only matters when you attempt to access a variable by a sequence of bytes rather than in its entirety. For all other purposes it does not matter.

If you use a variable as a whole, it doesn't matter what endianness you're system is using.


That said, all var types larger than 1 byte are subject to system endianness. So really the only type that isn't subject is char and unsigned char (and possibly bool).

As for a list of machines that are of a specific endianness, I couldn't help you there. Maybe someone else can chime in.
The endianness depends on the CPU. An easy way to find it is to look at the Wikipedia article. For example,
http://en.wikipedia.org/wiki/X86
http://en.wikipedia.org/wiki/ARM
http://en.wikipedia.org/wiki/SPARC
http://en.wikipedia.org/wiki/PowerPC

Can I use a specific kind of var type endianness independent ?
Not in any efficient way. Why would you care about this, though?

EDIT:
Additionally, there are ways to check the endianness at run time.
1
2
3
4
bool is_little_endian(){
    int v=0x1234;
    return *(char *)&v==0x34;
}
Last edited on
And the Operating system ?
Windows / linux / unix / mac-os ??
Thanks
The OS can only follow the endianness enforced by the CPU. You can't run a little endian OS on a big endian CPU.
Topic archived. No new replies allowed.