Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • 15
    If memory store data in 4 byte chunks then why its not adding 2 padding bytes to the unsigned short(its 2 byte long) ? or compiler just add padding bytes to 1st and last members of structure ? can you please clarify it. Commented Mar 6, 2014 at 11:33
  • 10
    @User Plz refer this too. If you still not clear, plz come for help stackoverflow.com/questions/11772553/… Commented Mar 6, 2014 at 11:47
  • 1
    Whoever said these padding bytes are meaningless does not know that misaligned data access is an oddity of x86 architecture. These bytes are necessary to avoid exceptions when processor tries to load - say an integer - data which straddles its natural alignment boundary. Commented Nov 20, 2019 at 6:27
  • 7
    @TanveerBadar they meant that the values of the padding bytes are meaningless, not their presence. Commented Sep 22, 2020 at 23:36
  • 1
    @MorElmaliach Padding happens wrt accessibility of members of the struct. Read the accepted answer of stackoverflow.com/questions/11772553/… thread for more clarity. Commented Nov 29, 2021 at 10:44

lang-c