Thought I knew what I read about it in the standard; but can't find him. Watching. Old; response header; not Q-tex; P:
The following program will determine that:
#include <stdio.h> #include <stdint.h> int is_big_endian(void) { union { uint32_t i; char c[4]; } e = { 0x01000000 }; return ec[0]; } int main(void) { printf("System is %s-endian.\n", is_big_endian() ? "big" : "little"); return 0; }
You also have this approach ; from Quake II:
byte swaptest[2] = {1,0}; if ( *(short *)swaptest == 1) { bigendien = false;
And !is_big_endian() not 100% smaller since it can be mixed / medium.
Believe me, this can be verified using the same approach, only the change value from 0x01000000 to ie 0x01020304 , giving:
switch(ec[0]) { case 0x01: BIG case 0x02: MIX default: LITTLE
But not quite sure about it ...
user1668559 09 Oct 2018-12-12T00: 00Z
source share