Alignment examples

The following examples use these symbols to show padding and boundaries:

p = padding

| = halfword (2-byte) boundary

: = byte boundary

Mac68K example

#pragma options align=mac68k
struct B {
    char a;
    double b;
     };
#pragma options align=reset
The size of B is 10 bytes. The alignment of B is 2 bytes. The layout of B is:
|a:p|b:b|b:b|b:b|b:b|

Packed example

#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:

Nested aggregate example

#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|