Today meet such a bug, when initial a struct with a redundant bytes, using struct a = {0}; the release build and debug build acts differently!
In the debug build, the redundant bytes are filled with 0xcc, while in the release build the redundant bytes are filled with 0x00.
Solution:
1 Use #pragma pack(1) . it’s better way, with more capacity, and efficiency.
2 call ZeroMemory().
本文探讨了在调试和发布构建中初始化结构体时出现的冗余字节填充差异问题。在调试构建中,冗余字节被填充为0xcc;而在发布构建中,则被填充为0x00。文章提供了两种解决方案:一是使用#pragmapack(1)进行内存布局调整;二是调用ZeroMemory()函数来显式清除内存。
4123

被折叠的 条评论
为什么被折叠?



