Live data from Hacker News

The Lost Art of C Structure Packing (2014)

catb.org

1–10 of 116 posts

Re: The Lost Art of C Structure Packing (2014)

#4
Very nice guide. I remember seeing extremely similar code when I was working with raw TCP packets and I always wondered what all the esoteric rules were for working with raw struct memory. There was no where that seemed to explain things happening on this level so it kind of just never made any sense to me. Guess now I can finally figure out what all that code meant, awesome.

Re: The Lost Art of C Structure Packing (2014)

#5
Sigh... apparently this is now enough of rocket science to be considered for posting on HN...

People using packing pragma of GCC should also beware -- an access to a field of a packed structure will be done bytewise, whether a variable happens to be actually aligned or not (I guess the compiler simplified its life by assuming no variable is ever aligned in packet structs), so memory size would go down but CPU use might grow.

At least this used to be true a few years ago, haven't reverified recently.

Re: The Lost Art of C Structure Packing (2014)

#9

great bit! still, but how often is this going to be reposted? https://hn.algolia.com/?query=The%20Lost%20Art%20of%20C%20St...

Every time we'd like another round of "Lost art? Why, I packed me some C structs this morning over breakfast! You young whippersnappers!" comments from crusty old C dudes.
Post reply on HN