Shop OBEX P1 Docs P2 Docs Learn Events
FlexProp: memory management of structs — Parallax Forums

FlexProp: memory management of structs

If I define a struct, for simplicity say containing 5 longs, do I have any guarantees how that will be structured in memory? Will it be 5 sequential addresses? If I need a specific mem layout is it better to define an array and use offsets?

Comments

  • If all the variables are longs then they will be laid out in memory the same way they are in the struct. If some of the variables are shorter, then there may be gaps introduced to make the longer variables be aligned on their "natural" boundaries (e.g. if there is a word and then a long, 16 bits of padding will be put between them to make the long start on a 32 bit boundary).

  • That's what I was hoping you'd say. :)

Sign In or Register to comment.