Boost logo

Boost Users :

From: Gavin Lambert (boost_at_[hidden])
Date: 2020-03-02 23:33:33


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).


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net