Keil™, An ARM® Company

C166 User's Guide

BYTEALIGN Compiler Directive

Abbreviation

None.

Arguments

None.

Default

Structure pointers point to word-aligned structures.

µVision

Options — C166 — Misc Controls.

Description

The BYTEALIGN directive generates code that supports pointers to structure members that may start on byte boundaries. This directive is required when you use the PACK(1) directive.

See Also

PACK

Example
#pragma pack(1)     /* byte alignment */
#pragma BYTEALIGN

struct s1  {
  int  i1;       // i1 has offset 0
  char c1;       // c1 has offset 2
  struct s2  {
    int  i2;     // i2 has offset 3
    char c2;     // c2 has offset 5
    int  i3;     // i3 has offset 6
  }s2;
  char z1;       // z1 has offset 8
} s1;

struct s2 *s2p;

void main (void)  {
  s2p = &s1.s2;   // pointer to byte-aligned struct
  s2p->i2 = 0;    // access to byte-aligned int
}