i have the following code:
#include
int
main(void)
{
float a[4] __attribute__((aligned(0x1000))) = {1.0, 2.0, 3.0, 4.0};
printf("%p %p %p %p\n", &a[0], &a[1], &a[2], &a[3]);
}
And i have the following output:
0x7fffbfcd2da0 0x7fffbfcd2da4 0x7fffbfcd2da8 0x7fffbfcd2dac
Why the address of `a[0]` is not a multiple of `0x1000`?
What exactly `__attribute__((aligned(x)))` does? I misunderstood [this][1] explanation?
I'm using gcc 4.1.2.
[1]: http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Variable-Attributes.html#Variable-Attributes
以上就是Are stack variables aligned by the GCC __attribute__((aligned(x)))?的详细内容,更多请关注web前端其它相关文章!