/*
** For internal use
*/
static bool g_bCheckByteOrder = false;
static bool g_bBigEndian = false;
bool isBigEndian()
{
if(g_bCheckByteOrder)
return g_bBigEndian;
union{
short inum;
char c[sizeof(short)];
}un;
un.inum = 0x0102;
/* check the byte order */
if(un.c[0] == 1 && un.c[1] == 2)
{
//g_bBigEndian = false;
g_bBigEndian = true;
}
else if(un.c[0] == 2 && un.c[1] == 1)
{
//g_bBigEndian = true;
g_bBigEndian = false;
}
g_bCheckByteOrder = true;
return g_bBigEndian;
}
阅读(2121) | 评论(3) | 转发(0) |