4.9 data_alignment Pragma
The IAR data_alignment
pragma controls the memory alignment of the variable
immediately following.
Suggested Replacement
There is no equivalent MPLAB XC8 pragma, but there is an attribute that performs a similar task.
The MPLAB XC8 aligned(n)
attribute aligns the
qualified object’s address with the next address that is a whole multiple of the
numerical value n
. If the CCI is enabled, a more
portable macro, __align(n)
(note the different
spelling), is available. This attribute works with automatic as well as static
storage duration objects.
Caveats
Note that the aligned
attribute is used to increase the alignment of
a variable, not reduce it. To decrease the alignment value of a variable, use the
packed
attribute.
Examples
#pragma data_alignment=4
char marker = 3;
to MPLAB XC8 code
similar to:char marker __attribute__((aligned(4))) = 3;
Further Information
See the Attributes section in the MPLAB XC8 C Compiler User's Guide for AVR MCUs for more information on this attribute.