1 #include<stdio.h> 2 int main() 3 { 4 int x = 1; 5 if(*(char*)&x == 1){ 6 printf("normal order "); 7 } 8 else{ 9 printf("not normal order, maybe powerpc "); 10 } 11 12 13 }
参考资料:Linux Kernel Development(Third Edition)书后末尾章节
以上在Ubuntu的笔记本电脑上测试通过,显示为正常字节序。