문제

간단한 구조물이 있습니다.

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 구현)를 사용하여 구축 된 경우 STL 유형 대신에 기본 유형을 공유 메모리 (예 : char*)에 넣어야합니까?

편집하다 :

나는 함께 시도했다

typedef boost::interprocess::basic_string<char> shared_string;

그리고 그것은 작동합니다!

도움이 되었습니까?

해결책

BOOST.NORTHPROCESS는 종종 공유 메모리의 사용을 위해 STL 유형에 대한 교체품을 제공합니다. STD :: String, 특히 구조물의 구성원만이 다른 프로세스에서 액세스 할 수없는 경우. 다른 사람들도있었습니다 그런 문제.

다른 팁

당신은 사용해야합니다

typedef boost::interprocess::basic_string<char> shared_string;
struct MyType
{
    shared_string name;
    shared_string description;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top