Tech Support > Microsoft Windows > Development Resources > Re: Why is the default struct member alignment 8 bytes in my compiler (vc++ 6)?
Re: Why is the default struct member alignment 8 bytes in my compiler (vc++ 6)?
Posted by Norman Black on June 25th, 2003


Alignment is handled in two parts. The alignment needed by the struct
which depends on the types of the field within the struct and the
compiler alignment setting. A struct that only needs 2 byte alignment
will be two byte aligned, not eight byte aligned. The type double needs
eight byte alignment, hence the default of 8 byte in the compiler.

If the alignment required is 4 and the compiler alignment is 2, then the
structure will be two byte aligned. Get the idea? The alignment used is
the lesser of the two values.

--
Norman Black
Stony Brook Software

<Robert S.> wrote in message
news:0qrhfvoavh46pcue6g8nmp6lld33ln6vu8@4ax.com...

Posted by Robert S. on June 27th, 2003


On Wed, 25 Jun 2003 13:09:17 -0700, "Norman Black" <nospam@nospam.com>
wrote:


Yes, you´re right. I had the wrong notion about alignment.

Robert S.