tom wrote:
hiw is calculated size of struct
Size of members, plus size of padding. Padding is any memory used for
internal
compiler purposes. E.g. you'll often see a difference if a struct has
virtual functions,
but also if the members have mixed type.
for example:
struct w1
{
char x1[252]; // 252
__int64 x2; // 8
// should be 260
// is 264; WHY ??
};
Note that you have mixed types here.
My guess in this case is that __int64 is a compiler-defined type that
has
alignment requirements. If it must start at an address that's a
multiple of 8,
then struct w1 must also. In an array of w1's, each w1 should. This in
turn
means the sizeof(w1) must be a multiple of 8.
It may also be a speed optimization - again a 'internal compiler
purpose'.
HTH,
Michiel Salters