[En-Nut-Discussion] size of CONFOS and CONFNET in AVR and ARM architectures

Thiago A. Corrêa thiago.correa at gmail.com
Tue Mar 3 21:20:47 CET 2009


Hi,

The packed attribute tells the compiler not to add fill space between
the members of the struct or it's end to keep it aligned.
It still could have differences in the size of the int though, so
there is no hard guarantee that the size is the same.

You should use sizeof instead of constant sizes, so, the compiler will
calculate it and you will be safe on any arch.

Kind Regards,
   Thiago A. Correa

On Tue, Mar 3, 2009 at 4:48 PM, José Vallet <jose.vallet at hut.fi> wrote:
> Hello all.
>
> I was wondering about the sizes that the Nut/OS and Nut/NET
> configuration parameters will take when stored in the non volatile
> memories, and I found in the code these definitions:
>
> typedef struct __attribute__ ((packed)) _CONFOS CONFOS;
>
> typedef struct __attribute__ ((packed)) _CONFNET CONFNET;
>
> So is the packed attribute used to guarantee that the CONFOS and CONFNET
> structures will occupy the same space in any arch and therefore will
> occupy the same size when stored in non volatile memory?
>
> Or in other words: do they occupy the same space if I use the NutNvMem*
> functions in different archs? The point here is to be sure that I don't
> write my app specific config data on top of those in the non volatile
> memory.
>
> Regards
> J.
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>



More information about the En-Nut-Discussion mailing list