Variable Attributes

The variable attributes aligned and packed are optional in declarations and do not actually affect the type of variable.

Attribute aligned

This attribute specifies a minimum alignment for the variable or structure field, measured in bytes. For example, the declaration :

int x aligned(16);

or alternative syntax :

int x __attribute__ ((aligned(16)));

This will cause the compiler to allocate the global variable x on a 16-byte boundary.
The aligned attribute can only increase the alignment, but you can decrease it by specifying packed as well.

Attribute packed

The packed attribute specifies that a structure field should have the smallest possible alignment, one byte for a variable and one bit for a field, unless you specify a larger value with the aligned attribute.
Here is a structure in which the field x is packed, so that it immediately follows a:

struct foo {
  char a;
  int x[2] __attribute__ ((packed));
};
Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code