[Interprocess] Using shared Memory with different compilers (msvc, mingw)

hi,
My library uses boost::interprocess' Shared Memory and has to be delivered with msvc(7.1) and mingw compiled versions.
Every instance of the that library opens a connection to the Shared Memory "sharedMemoryMapTest" and communicates via instances of the class "SyncObject".
In my test program ProcessA opens the shared memory, instanciates a SynObject with the identifyer String "id1". ProcessB connects to the same SyncObject and synchronizes with ProcessA.
If ProcessA and ProcessB are both compiled with the same compiler it works fine. If one process is compiled with mscv and the other is compiled with mingw it fails. (mscv = ProcessA, ProcessB = mingw -> I read my Windows environment variables instead of "id1")
Did I make a mistake in my implementation, or is it simply not possible to access the same Shmem with different compiled versions?
Thanks in advance
Martin
(compilable) code:
#include <iostream>
#include

AMDG BaDBuTz wrote:
My library uses boost::interprocess' Shared Memory and has to be delivered with msvc(7.1) and mingw compiled versions.
Every instance of the that library opens a connection to the Shared Memory "sharedMemoryMapTest" and communicates via instances of the class "SyncObject".
In my test program ProcessA opens the shared memory, instanciates a SynObject with the identifyer String "id1". ProcessB connects to the same SyncObject and synchronizes with ProcessA. If ProcessA and ProcessB are both compiled with the same compiler it works fine. If one process is compiled with mscv and the other is compiled with mingw it fails. (mscv = ProcessA, ProcessB = mingw -> I read my Windows environment variables instead of "id1")
Did I make a mistake in my implementation, or is it simply not possible to access the same Shmem with different compiled versions?
You can't use std::string in shared memory. It probably works in this case because of SBO. Regardless, you can't safely use Interprocess with different compilers because the ABI can be different depending on the compiler. In Christ, Steven Watanabe

hi Steven,
I'll change the std::string to boost::interprocess::basic_string::string
or basic_string.
What does SBO stand for? I searched the web but couldn't find anything.
Can I use interprocess with different compilers, if I store the elements
of the SyncObject(U32 values, mutexes, strings) directly in the Shmem
without wrapping them into the SyncObject container?
example:
pMtxReadWrite = segment.construct
AMDG
BaDBuTz wrote:
My library uses boost::interprocess' Shared Memory and has to be delivered with msvc(7.1) and mingw compiled versions.
Every instance of the that library opens a connection to the Shared Memory "sharedMemoryMapTest" and communicates via instances of the class "SyncObject".
In my test program ProcessA opens the shared memory, instanciates a SynObject with the identifyer String "id1". ProcessB connects to the same SyncObject and synchronizes with ProcessA. If ProcessA and ProcessB are both compiled with the same compiler it works fine. If one process is compiled with mscv and the other is compiled with mingw it fails. (mscv = ProcessA, ProcessB = mingw -> I read my Windows environment variables instead of "id1")
Did I make a mistake in my implementation, or is it simply not possible to access the same Shmem with different compiled versions?
You can't use std::string in shared memory. It probably works in this case because of SBO. Regardless, you can't safely use Interprocess with different compilers because the ABI can be different depending on the compiler.
In Christ, Steven Watanabe
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

AMDG BaDBuTz wrote:
I'll change the std::string to boost::interprocess::basic_string::string or basic_string.
What does SBO stand for? I searched the web but couldn't find anything.
Small buffer optimization. In this case, it means that small strings will be stored directly in the string object instead of being allocated on the heap.
Can I use interprocess with different compilers, if I store the elements of the SyncObject(U32 values, mutexes, strings) directly in the Shmem without wrapping them into the SyncObject container?
example: pMtxReadWrite = segment.construct
(id.c_str() + "_mtx"); plocAddrSp0Range = segment.construct<U32>(id.c_str() + "_locAddrSp0Range"); then I use the pointers now as if they are in the SyncObject before.
I don't think it matters. Unless the internal data structures used by Interprocess and all the types involved have exactly the same layout you can't use managed_shared_memory with different compilers. In Christ, Steven Watanabe
participants (3)
-
BaDBuTz
-
BaDBuTz
-
Steven Watanabe