Re: ::CreateDialogIndirect messes with *MY* class memory



Torsten Wirz wrote:
After recompilation the m_sJustForMe is (as it should be!) untouched and
instead the first two components of the int vector are zeroed while the
rest of the lot remains uninialized. So the mysterious access on my class
memory is symbol independent.

During a long debugging session I traced the wrongdoer down to be the Win32
call ::CreateDialogIndirect somewhere inside CDialog::DoModal.

This could happen if you set different values for structure member alignment (or strucure packing). One cpp sees the class as pack 1, and another sees it as pack 4. Packing is changed with option "Struct Member Alignment" in Configuration Options > C/C++ > Code Generation, or with #pragma pack directive. #pragma pack directives must come in pairs, one to set something, and another to revert it to what it was before, like this:


#pragma pack(push, 1)
// some class, or struct, or whatever
#pragma pack(pop)
.