Keil™, An ARM® Company

RealView Compiler User's Guide

About data alignment

4.5.1. About data alignment

All accesses to data in memory can be classified into the following categories:

  • Natural alignment, for example, on a word boundary at 0x1000. The ARM compiler normally aligns variables and pads structures so that these items are accessed efficiently using LDR and STR instructions.

  • Known but non-natural alignment, for example, a word at address 0x1001. This type of alignment commonly occurs when structures are packed to remove unnecessary padding. In C and C++, the __packed qualifier is used to signify that a structure is packed.

  • Unknown alignment, for example, a word at an arbitrary address. This type of alignment commonly occurs when defining a pointer that can point to a word at any address. In C and C++, the __packed qualifier is used to signify that a pointer that can access a word on a non-natural alignment boundary.

See The __packed qualifier and unaligned accesses to data for more information about the __packed qualifier, packed structures, and unaligned pointers.

Copyright © 2007 ARM Limited. All rights reserved.ARM DUI 0375A