The following examples use these symbols to show padding and boundaries:
p = padding
| = halfword (2-byte) boundary
: = byte boundary
#pragma options align=mac68k
struct B {
char a;
double b;
};
#pragma options align=reset
|a:p|b:b|b:b|b:b|b:b|
#pragma options align=bit_packed
struct {
char a;
double b;
} B;
#pragma options align=reset
The size of B is 9 bytes. The layout of B is:
|a:b|b:b|b:b|b:b|b:
#pragma options align=mac68k
struct A {
char a;
#pragma options align=power
struct B {
int b;
char c;
} B1; // <-- B1 laid out using power alignment rules
#pragma options align=reset // <-- has no effect on A or B,
but on subsequent structs
char d;
};
#pragma options align=reset
The size of A is 12 bytes. The alignment
of A is 2 bytes. The layout of A is:
|a:p|b:b|b:b|c:p|p:p|d:p|
In 32-bit mode:
#pragma options align=natural
class A {
double _a;
} sa;
class C : public A {
public:
virtual void f() {}
private:
char* name;
} sc;
|a:a|a:a|a:a|a:a|f:f|f:f|p:p|p:p|n:n|n:n|p:p|p:p|