今天做了一个IP电话服务程序,通过接收消息来执行拨打电话的功能。消息中用了word类型,所以我将VC6
的struct member alignment设置为1 byte。结果本来运行正常的程序一拨号就报错,郁闷了半天才发现是PString::IsEmpty()的问题,我估计PString::IsEmpty()是按struct member alignment为8来进行运算的。改回8 byte后一切正常了。
但为了方便取消息中的word类型变量,还得需要将消息的结构体按1 byte来运行,所以在结构体的前面加上#pragma pack(push,1) ,在结构体后面加上#pragma pack(pop)即可。
学习啊,学习,碰壁阿碰壁,....
的struct member alignment设置为1 byte。结果本来运行正常的程序一拨号就报错,郁闷了半天才发现是PString::IsEmpty()的问题,我估计PString::IsEmpty()是按struct member alignment为8来进行运算的。改回8 byte后一切正常了。
但为了方便取消息中的word类型变量,还得需要将消息的结构体按1 byte来运行,所以在结构体的前面加上#pragma pack(push,1) ,在结构体后面加上#pragma pack(pop)即可。
学习啊,学习,碰壁阿碰壁,....