4.30 Types of data alignment

All access to data in memory can be classified into a number of different categories.

These categories are as follows:
  • Natural alignment, for example, on a word boundary at 0x1004. 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 or the #pragma pack(n) pragma let you 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 or the #pragma pack(n) pragma let you signify that a pointer can access a word on a non-natural alignment boundary.
Related concepts
4.31 Advantages of natural data alignment
4.34 Unaligned data access in C and C++ code
4.35 The __packed qualifier and unaligned data access in C and C++ code
Related reference
4.32 Compiler storage of data objects by natural byte alignment
4.33 Relevance of natural data alignment at compile time
9.93 #pragma pack(n)
Non-ConfidentialPDF file icon PDF versionARM DUI0375F
Copyright © 2007, 2008, 2011, 2012, 2014 ARM. All rights reserved.