Write a struct to a file and just rely on however your particular compiler chooses to align things and you'll get what you deserve. Define your file format and write things where you want them and you'll become one with the universe.
The compiler will lay out a struct in a way that is optimal for in-memory access. You don't want to use __attribute__ ((packed)) on anything that's not explicitly and only used for reading and writing external media. Even then, you still have to deal with endian issues.