Hello,
I created a simple class for storing information
in shared memory (native Windows):

template<
classdata>
structSharedData
{
  SharedData<data>():
    value(0),
    var(0.0),
    written(1),
    read(0){
      std::cout<<"  Objekt bei "<<this<<" erzeugt!"<<std::endl;}
   
  intvalue; // just temporary, will be replaced by a more generic data type
  doublevar; // just temporary, will be replaced by a more generic data type
  boost::interprocess::interprocess_semaphorewritten,read;
};


I created and mapped
that memory like:

boost::interprocess::windows_shared_memoryshm (create_only,name,read_write,sizeof(SharedData<data>));
boost::interprocess::mapped_regionregion(shm,read_write);

and assigned a new data structure to it's address with:

pShared= new(region.get_address()) SharedData<data>();

with pShared:
SharedData<data>*        pShared;

But when I try to access the stored data with this pointer
my program simply quits.
Probably I am making a really silly mistake?

Kind regards,
Thomas

Tel.: +49 2762 408-0
Fax.: +49 2762 408-10

Internet: http://www.camcoaudio.com

CAMCO Produktions- und Vertriebs-GmbH für Beschallungs- und Beleuchtungsanlagen - Fischpicke 5 - 57482 Wenden - Amtsgericht Siegen HRB 7075 - Geschäftsführer: Joachim Stöcker, Reiner Sassmann, Carsten Wegner