Order of structure members in memory

  • Thread starter Christopher Benson-Manica
  • Start date
C

Christopher Benson-Manica

Are the members of a struct guaranteed to have ascending memory
addresses?
 
D

Derrick Coetzee

Christopher said:
Just for my edification, what is the chapter and verse? Thanks...

In C90, it's 6.5.2.1, verse 11:

"Within a structure object, the non-bit-field members and the units in
which bit-fields reside have addresses that increase in the order in
which they are declared."

This is a bit vague, since you don't technically declare the units
bit-fields reside in (but rather the bit-fields that go in them, but
adjacent bits fields do go into each unit). Bit-field members within a
unit are in implementation-defined order.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top