News for hackers. Stuff that matters.
Re:How Structs Really Work in C by p9idf on Sunday October 16, 2011 @03:52AM (#3116827)
"memcpy(&v, video_loc_in_memory, sizeof(struct video_file));

"Well, here's the problem: if padding bytes are involved, you could be entering a world of pain and not even know it. [...] The solution is to use a compiler switch or a #pragma pack to ensure that structs are packed (i.e., no padding applied)."

That's an implementation-defined hack. The correct solution is to explicitly marshal your data between its in-memory format and the required external representation.

There are no comments on this comment yet.