Keil Logo

Byte Alignment

The various C data types are aligned on specific byte boundaries to maximize storage potential and to provide for fast, efficient memory access with the ARM instruction set. For example, the ARM architecture can access 4-byte variables using one instruction only when the object is stored at an address divisible by four. So, 4-byte objects are located on 4-byte boundaries.

By default, the CARM Compiler stores data objects as follows:

Type Bytes Alignment
char 1 Located at any byte address.
short 2 Located at an address evenly divisible by 2.
float,
int,
long,
pointer
4 Located at an address evenly divisible by 4.
long long,
double
8 Located at an address evenly divisible by 4.

Note

  • Alignment is relevant when the compiler locates variables to physical memory addresses. For instance, in the following struct:
    struct example_st
      {
      int  amem;
      char bmem;
      int  cmem;
      };
    

    a 3-byte gap is required between bmem and cmem.

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.