Hi,

 

I have some code which shares data with shared memory.  To that end, I’m using boost::interprocess:managed_shared_memory.  Without respect to scope and functions, what I have is roughly:

 

boost::interprocess::managed_shared_memory  sharedMem(boost::interprocess::create_only, “SharedMemory”, 4096);

 

//later on

u_int8_t* dataSegment = sharedMemory.construct<u_int8_t>(“data”)[5](0);

char* string1 = sharedMemory.construct<char>(“String 1”)[50](‘\0’);

// other stuff

 

// placing stuff in the data segment

for(int i(0); i < 5; i++) dataSegment[i] = anEarlierArray[i];

 

 

// then, in other process read the data Segment

char ary[5];

for(int i(0); i< 5; i++) ary[i] = dataSegment.first[i];

 

 

For whatever reason I couldn’t simply access through dataSegment[n] notation.  The weirdest thing is, the data is being read back to me in the reverse order that it should be.  For example, if [0x2,0x4,0x7,0x1] is written I read it back as [0x1,0x7,0x4,x02] even though I’m writing and reading in the same order.  Why is this?  What is it I’m missing about using shared memory?

 

Thanks,

Andy