Live data from Hacker News

The Lost Art of C Structure Packing (2014)

catb.org

11–20 of 116 posts

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

#11
Strange that he doesn't mention dwarves (https://github.com/acmel/dwarves/ http://www.ukuug.org/events/linux2007/2007/papers/Melo.pdf).

Edit: He does mention it in passing but says he hasn't used it. Suggest that he does use it because it's a really useful tool and lots of the manual stuff he's doing is better done automatically.

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

#12
post #6

It concerns me when a technique I've used this week is called a "lost art". I'd suggest putting a [NOOB] tag on this kind of post. Except ESR wrote this one. So maybe [FAUX-NOOB].

Agreed. It is also taught by at least one university (UIUC) in a required class (in 2016.) Not a lost art.

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

#13

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 mig…

You mean that it reads the values into single byte registers and assembles those back into the value you want?

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

#14
post #3

Ah, yes. BUS ERROR: http://blog.jgc.org/2007/04/debugging-solaris-bus-error-caus...

John Graham-Cumming that blog's author seems like an interesting guy, he's started something called 'Plan 28' to faithfully build Charles Babbage's Analytical Engine. He also wrote the Geek Atlas.

Blast form the past, I remember Bus Errors from Solaris days.

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

#16
post #6

It concerns me when a technique I've used this week is called a "lost art". I'd suggest putting a [NOOB] tag on this kind of post. Except ESR wrote this one. So maybe [FAUX-NOOB].

Hey kids! ESR here. I'm the last programmer on earth. The very definition of a hacker. (Coincidentally I also wrote that definition.)

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

#17
post #3

Ah, yes. BUS ERROR: http://blog.jgc.org/2007/04/debugging-solaris-bus-error-caus...

John Graham-Cumming that blog's author seems like an interesting guy, he's started something called 'Plan 28' to faithfully build Charles Babbage's Analytical Engine. He also wrote the Geek Atlas. Blast form the past, I remember Bus Errors from Solaris days.

That would be me.

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

#18
post #6

It concerns me when a technique I've used this week is called a "lost art". I'd suggest putting a [NOOB] tag on this kind of post. Except ESR wrote this one. So maybe [FAUX-NOOB].

I had two job interviews last year for embedded software positions and in both of them struct packing had come up. I don't think it's a lost art.

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

#20
Knowing about struct memory alignment can come in in very handy when reverse-engineering 3rd party binary protocols. Often you come across many "unknown" bytes which turned out they were just padding because of 4 byte struct alignment and could be discarded. Saved a bunch of time not having to try to figure out what they were.
Post reply on HN