Are packed structs slower AND safe?

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

__attribute__((packed))

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?

Reply to
pozz
Loading thread data ...

Post the structure with the variable names changed to Greek gods. Add comments to each line with the range of values stored in each variable.

Reply to
Brett

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.