Here's a piece of code that directly tests the endian of the machine. Basically, it looks at how the number 1 is stored. In the 4 byte int, if its NDR, it will be in the 1st byte. If its XDR, it'll be in the last byte. int test = 1; if ( (((char *)(&test))[0]) == 1) { //NDR } else { //XDR }