Different Member Alignment/Padding was the problem.
I observed that across two modules the size of CGenericReport
was different: 136 vs. 134 while including the same header file.
In one case the m_defaultCX
member was located directly after the 2 byte member m_dmOrient
while in the other module 2 bytes were included to pad to 8 byte alignment.
Then I checked the alignment settings in the project properties (/Zp, Struct Member Alignment in tab Code Generation in C/C++). Both were set to Default (= 8 byte according to the documentation).
However, when I inserted a
#pragma pack(show)
into the CGenericReport
header file, the compiler reported
warning C4810: value of pragma pack(show) == 8
...
warning C4810: value of pragma pack(show) == 1
for this spot in varying order.
Finally I cotton on to a #pragma pack directive
#pragma pack(1)
being used at the end of another header that overrode the project settings and caused this behavior.
Removing it released me from this trouble. Now the packing alignment of CGenericReport
is the same for every module.