ARM Technical Support Knowledge Articles


Applies to: CARM C Compiler


Information in this article applies to:


I have an array of byte (unsigned char) values. Since my source code uses some tricks to access this array, I want to force the char variable to a 32-bit (int) boundary. Is there a way to change the alignment with a C pragma directive?


The CARM User's Guide contains a section that discusses how to align variables to various boundaries. While it is possible to change the default alignment for int or short to a byte-alignment, it is not possible to force char variables to a 32-bit alignment.

However, you may define the char array in a union that contains an int variable as shown below:

union u {
  unsigned char c[10];  // the char array
  unsigned int  i;      // force 32-bit int alignment

  union u array;
  array.c[i] = 0;       // access to int-align char array


Article last edited on: 2005-07-15 12:43:53

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential