Do not optimise the contents of a function
__attribute__((optimize(0))) void MyFunction()
{
}
Remove the in and out code for a function
The compiler does not generate prologue and epilogue sequences for functions with:
__attribute__((naked)) void MyFunction()
{
}
Avoiding Padding
You can used the packed variable attribute. For example in the following code, type c_t will have a size of 3 bytes and there will be no wasted space between a and b:
typedef struct
{
unsigned char a[1];
} __attribute__ ((packed)) a_t;
typedef struct
{
unsigned char b[2];
} __attribute__ ((packed)) b_t;
typedef struct
{
a_t a;
b_t b;
} __attribute__ ((packed)) c_t;
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.