If I have a struct
in C++, is there no way to safely read/write it to a file that is cross-platform/compiler compatible?
Because if I understand correct
No, there's no safe way. In addition to padding, you have to deal with different byte ordering, and different sizes of builtin types.
You need to define a file format, and convert your struct to and from that format. Serialization libraries (e.g. boost::serialization, or google's protocolbuffers) can help with this.