As subject says, I got different result of the same operation that calculate a same structure. The struct is below.
struct test
{
char m1;
double d1;
}
When use sizeof(struct test) calculate it in gcc-4.6.3 and gcc-4.2 in linux, I got the result "12". While I use gcc-4.6.1 in linux and VC 6.0 in WinXP, I got the result "16". So I'm confused, why this happen? How GCC calculate a struct's size?
added:
as the answers say,arm linux require 8-byte alignment for AAPCS defines,but why vc 6.0 in x86 get the result "16"?Does anyone use vc 2003 or later calculate this?
what's more does C standard such as C89/C99 define this?