判断字节序
// 1: big-endian 0:little-endian
typedef union
{
short a;
char b[2];
}UNION;
int isBigEndian()
{
UNION s;
s.a = 0x0001U;
return s.b[0]==0;
}
判断字节序
// 1: big-endian 0:little-endian
typedef union
{
short a;
char b[2];
}UNION;
int isBigEndian()
{
UNION s;
s.a = 0x0001U;
return s.b[0]==0;
}