Re: ::CreateDialogIndirect messes with *MY* class memory
- From: Mihajlo Cvetanović <mac@xxxxxxxxxxxxxxxxxx>
- Date: Mon, 13 Jun 2005 15:04:08 +0200
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) .
- References:
- ::CreateDialogIndirect messes with *MY* class memory
- From: Torsten Wirz
- ::CreateDialogIndirect messes with *MY* class memory
- Prev by Date: Re: Dynamic Dialog
- Next by Date: CoCreateInstance return REGDB_E_CLASSNOTREG
- Previous by thread: ::CreateDialogIndirect messes with *MY* class memory
- Next by thread: CSplitterWnd object not valid
- Index(es):