I\'m trying to write a tool that will take as input some C code containing structs. It will compile the code, then find and output the size and offset of any padding the com
I prefer to read and write into a buffer, then have a function load the structure members from the buffer. This is more portable than reading directly into a structure or using memcpy
. Also this algorithm frees up any worry about compiler padding and can also be adjusted to handle Endianess.
A correct and robust program is worth more than any time spent compacting binary data.