| |||
| Home > Compiler Coding Practices > Types of data alignment | |||
All access to data in memory can be classified into the following categories:
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( pragma is used to signify
that a structure is packed.n)
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( pragma
is used to signify that a pointer can access a word on a non-natural
alignment boundary.n)