我有一個簡單的結構:升壓進程間:共享內存和STL類型
struct MyType
{
std::string name;
std::string description;
}
,我把它在一個共享內存:
managed_shared_memory sharedMemory(open_or_create, "name", 65535);
MyType* pType = sharedMemory.construct<MyType>("myType")();
// ... setting pType members ...
如果兩個應用程序共享通信內存是使用不同版本的Visual Studio(不同版本的stl實現)構建的,我應該將本機類型放在共享內存中(例如char *)而不是stl類型?
編輯:
我試着用
typedef boost::interprocess::basic_string<char> shared_string;
和它的作品!
呀,請參閱本節文檔:http://www.boost.org/doc/libs/1_39_0/doc/html/interprocess/allocators_containers.html#interprocess。 allocators_containers.containers_explained – 2009-08-13 13:58:12