彼らがここhttp://en.wikipedia.org/wiki/Data_structure_alignmentで言ったように、私は常に、「構造の合計サイズが任意の構造体メンバーの最大アライメントの倍数"
したがって、このような構造体の場合、そのサイズは 32 プロセッサで 16 になります。
typedef struct
{
double s; /* 8 bytes */
char c; /* 7 bytes padding at the end of make the total size 8*2 */
} structa_t;
で、サイズが16ではなく12でビックリ!何故ですか ?誰かがそれに光を当てることができますか?
sizeof(double) = 8
sizeof(structa_t) = 12
ところで、システム情報
$ uname -a
Linux 2.6.18-8.el5xen #1 SMP Thu Mar 15 21:02:53 EDT 2007 i686 i686 i386 GNU/Linux
$ gcc --version
gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-52)