Struct varies in memory size?

The compiler is allowed to add padding between struct members to make processing more efficient. This padding varies by platform, compiler version etc. It's one of the things that make sending structs over the network impossible.

You can use offsetof to find out where exactly your compiler is adding paddings.


As the previous answer indicated, the compiler is allowed to add padding. This is usually done because sometimes the hardware requires that certain data types must occur on certain memory boundaries. It looks like your system wants to put pointers on an 8-byte boundary.

The padding is at the end of the structure and is necessary so that each element in an array of struct desc will still be on an 8-byte boundary.