标签:
在大端机器(solaris-sparc,hpux-hppa)上从奇数内存地址取一个整形(2 or 4 bytes)会崩溃。如:
unsigned short Res = *(unsigned short *) tmpArray;
应该:
char tmpArray[sizeof(unsigned short)] = {0};
for(int i = 0; i < sizeof(unsigned short); ++i)
{
tmpArray[i] = *(pcNewHdr + i);
}
unsigned short Res =*(unsigned short *) tmpArray;
标签:
原文地址:http://www.cnblogs.com/playerken/p/4182568.html