#pragma pack( [ n] )Specifies packing alignment for structure and union members. Whereas the packing alignment of structures and unions is set for an entire translation unit by the /Zp option, the packing alignment is set at the data-declaration level by the pack pragma. The pragma takes effect at the first structure or union declaration after the pragma is seen; the pragma has no effect on definitions.When you use #pragma pack(n), where n is 1, 2, 4, 8, or 16, each structure member after the first is stored on the smaller member type or n-byte boundaries. If you use #pragma pack without an argument, structure members are packed to the value specified by /Zp. The default /Zp packing size is /Zp8.为了加快structure的访问速度,通常编译器会调整结构中成员的位置,使每个成员的offset地址都是2的n次方,在特殊情况下如在网络中,需要pass this structure to another program in another computer, it does not know how to change member position of the structure,so you have to pass unchanged structure to it. to prevent compiler change member offset position of the structure, use #pragma pack(1)
解决方案 »
- 在xp下编译的exe在vista下兼容的问题
- VB调用VC DLL的参数问题:为我的错误回答向受害者致歉。散分。
- 各种套节字i/o模型下如何创建套节字?
- 求可视化网络监测源代码,谢谢哈
- 语句 CObject *(PASCAL * m_pfnCreateObject)() 怎么理解?
- 我的“程序间碟”1.2版发布了,新加了动态监视其它程序API调用等功能,欢迎大家试用。
- 将c语言中的malloc 换成数组表示,需要注意那些地方?重分答谢!
- VC中如何在非模对话框中获得当前的View,或者说如何使当前的View重画,因为当前view不是active状态,所以不知道还有什么函数可用。请赐教
- 如何控制鼠标,用程序控制它自己在屏幕上动。
- 可以“穿墙入室”的远程文件访问软件 - 网络神偷!
- 关于进度条
- 关于校园网的建设问题:
所以......
看看BITMAPFILEHEADER就知道了,它是14个字节,而不是16BYTE
看看它在wingdi.h中的定义,它include <pshpack2.h>