4 ms·
"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 an
by p9idf 15y ago
"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.