Thank you for the reply. 

Right now, I am actually stuck in Boost's segment manager. Its own data structure got scrambled in the memory. I haven't even gotten to where my own data structure gets read.

If I do go with the bare metal approach,  I will definitely keep these advice in mind.


Da.

On Monday, March 2, 2020, 06:33:55 PM EST, Gavin Lambert via Boost-users <boost-users@lists.boost.org> wrote:


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 mailing list
Boost-users@lists.boost.org
https://lists.boost.org/mailman/listinfo.cgi/boost-users