Difference between release and debug build when initial a struct

来源:互联网 发布:淘宝物流交易怎么发货 编辑:程序博客网 时间:2024/05/22 01:27

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().