In the final draft of the C ++ 11 standard , chapter 3.11 talks about alignment.
Chapter 7.6.1 later defines how to define aligned structures (or variables?)
If I define the structure as follows:
alignas(16) struct A { int n; unsigned char[ 1020 ]; };
Does this mean that all instances of class A will be aligned with 16 bytes?
Or do I need to do this, as in the following code?
struct A { char data[300]; }; alignas(16) A a;
If both examples are wrong, how to do it right?
PS I'm not looking for a compiler dependent solution.
source share