Is the amount of padding in structure in C is Compiler dependent or well defined?

c, padding

Solution

It is implementation-defined. From section 6.7.2.1 of the C99 standard:

...Each non-bit-field member of a structure or union object is aligned in an implementation-defined manner appropriate to its type...

...There may be unnamed padding within a structure object, but not at its beginning...

The compiler will typically choose an arrangement that suits the underlying hardware (aligning things to be easy to read from memory, etc.).

Problem

Is the a amount of padding in C `struct` well defined in standards or compiler and/or target architecture dependent. I could not find an answer in the standards.

Original source