
Hi, I am having trouble using offset_ptr. I want to dynamically allocate memory in windows shared memory and create a point to it so it can be used by two different processes. I figures I would create a named object in the shaed memory to contain the pointer to the memmory, but when I try it I get a compile error. Here is the code I have so far. Note the the the shared memory is created elsewhere and it is big enough. bip::managed_windows_shared_memory* pAldisSharedMemory = new bip::managed_windows_shared_memory(bip::open_only, ALDIS_SHARED_MEMORY_NAME.c_str()); if (pAldisSharedMemory) { bip::offset_ptr<char> pImageData; // // This line causes the following error. Error 1 error C2440: 'initializing' : cannot convert from //' //boost::interprocess::offset_ptr<PointedType> *' to 'char *' //C:\stopbar\3rdParty\boost\include\boost\interprocess\offset_ptr.hpp 111 AldisHardware // pImageData = pAldisSharedMemory->find_or_construct<bip::offset_ptr<char>>("ImageData")(); // char * *pImageData = pAldisSharedMemory->find_or_construct<char *>("ImageData")(); if (pImageData == NULL) { // // This value will be unuseable by other processes, need to use an offset_ptr here, but I have not figured // out yet how to make them work. // pImageData = (char *)pAldisSharedMemory->allocate(1280 * 860 * 3); } I have really no idea what is wrong or how to do this. If anybody has any examples, that would be great. Thanks Rex
participants (1)
-
Rex Battenberg