flâneur — a map of the web's best reading

Struct padding in C++ - Stack Overflow

stackoverflow.com · 2,921 words · saved by 1 readers

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 correctly, every compiler 'pads' differently based on the target platform. No. That is not possible. It's because of lack of standardization of C++ at the binary level. Don Box writes (quoting from his book Essential COM, chapter COM As A Better C++) Once the decision is made to distribute a C++ class as a DLL, one is faced with one of the fundamental weaknesses of C++, that is, lack of standardization at the binary level. Although the ISO/ANSI C++ Draft Working Paper attempts to codify which programs will compile and what the semantic effects of running them will be, it makes no attempt to standardize the binary runtime model of C++. The first time this problem will become evident is when a client tries to link against the FastString DLL's import library from a C++ developement environment other than the one used to build the FastString DLL.

Struct padding in C++ - Stack Overflow New: Stack Overflow For Agents. The next generation of knowledge exchange. Learn more Collectives™ on Stack Overflow Find centralized, trusted content and collaborate around the technologies you use most. Learn more about Collectives Stack Internal Knowledge at work Bring the best of human thought and AI automation together at your work. Explore Stack Internal Struct padding in C++ Ask Question Asked 15 years, 3 months ago Modified 6 years, 8 months ago Viewed 102k times 74 If I have a struct in C++, is there no way to safely read/write it to a file that

Explore this link on the map →

saved by

related reading