News for hackers. Stuff that matters.
Re:How Structs Really Work in C by keeperofdakeys on Sunday October 16, 2011 @04:56AM (#3116903)
Many compilers insert padding bytes into the struct to ensure the fields are byte-aligned. What's worse, they often do this by default.

The way this guy explains it, he makes it sound optional, when it isn't. You can't use misaligned addresses on pretty much every piece of hardware. Compilers make a choice between time and effort, it is much easier to just pad a struct then try to juggle elements around until it takes up the least space. The onus is on the programmer to order their struts properly if they really care heavily about memory.

There are no comments on this comment yet.