C函数检测CPU架构为Little-Endian或Big-Endian

//返回1说明是Little-Endian,否则为Big-Endian
int CheckCpu(){
//联合体从低位开始存储
union w{
int i;
char b;
} u;
u.i
=1;
return (u.b==1);
}

 

C检测CPU架构为Little-Endian或Big-Endian.

posted @ 2010-07-01 16:09  庚武  Views(286)  Comments(0Edit  收藏  举报