On 3/03/2020 08:37, Da Xu wrote:
Thank you guys. Yah, the problem is that the pieces I am writing are all DLLs. And of course, gcc DLL and Msvc DLLs aren't compatible. Therefore, I HAVE to use two compilers.
So, clang might produce data structure layout that might be compatible with gcc?
If you confine your shared memory interface to POD types that use well-known-sized fields, then most compilers will produce a compatible binary layout. (With a few quirks to watch out for, such as default padding and potentially different sizes for "int", "long", "size_t", "time_t", etc. It doesn't hurt to explicitly static_assert(sizeof(T) == known_constant) in both compilers.) It's when you introduce non-POD C++ types that you typically run into trouble. For example, library types such as std::string are not guaranteed to have equivalent binary layout across different compilers (or even different compiler versions).