In one of my projects that run on a Cortex-M0+ MCU, I have a few arrays of structs. Now I need to increase the size of the arrays, but I'm out of RAM, so I'm searching for ways to save some space in RAM.
One simple way is to pack the structs, for example with
in gcc. I can save some padding bytes (that waste some memory) for each element of the array, so the total amount of saved space could be enough.
I know the use of a packed struct forces the compiler to generate a slower code, because of misaligned accesses of its members. However, besides having a slower code, is the result correct in any case?