will __attribute__((aligned(CACHE_LINE_SIZE))) break struct alignment

陳韋任 chenwj.cs97g@g2.nctu.edu.tw
Mon Nov 6 11:57:00 GMT 2017


I think not. Maybe you can look up
https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#Common-Variable-Attributes
?

2017-11-06 13:04 GMT+08:00 Yubin Ruan <ablacktshirt@gmail.com>:

> Hi,
>
> I am using something like this:
>
>   struct S1 {
>     int index __attribute__((aligned(CACHE_LINE_SIZE)));
>     struct S2 some_other;
>   };
>
> I am not using anything like `#pragma pack`.
>
> I am wondering whether adding that
> `__attribute__((aligned(CACHE_LINE_SIZE)))` will break GCC's automatic
> alignment for S1 and S2. Can anyone point me to any document which
> specify this behavior?
>
> Thanks,
> Yubin
>



-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj



More information about the Gcc-help mailing list