[boost::interprocess]trouble creating a vector in a shared memory segment

I'm having some trouble creating a vector in a shared memory segment (compilation errors) The code: int main(){ //Allocator for the event list typedef boost::interprocess::allocator <int,managed_shared_memory::segment_manager> EventAllocator; //the in memory vector of events typedef boost::interprocess::vector<int, EventAllocator> EventList; //is it already created? EventList* pEventList = segment.find<EventList>(EVENTSEGMENT_NAME).first; } The error: d:\boost_1_35_0\boost\preprocessor\iteration\detail\local.hpp(37): error C2036: 'EventList *' : unknown size And the trace: DataHandle.cpp(53) : warning C4101: 'ex' : unreferenced local variable d:\boost_1_35_0\boost\interprocess\mem_algo\rbtree_best_fit.hpp(353) : see reference to class template instantiation 'boost::interprocess::rbtree_best_fit<MutexFamily,VoidPointer,MemAlignment>' being compiled d:\boost_1_35_0\boost\preprocessor\iteration\detail\local.hpp(37) : error C2036: 'EventList *' : unknown size d:\boost_1_35_0\boost\preprocessor\iteration\detail\local.hpp(37) : see reference to class template instantiation 'boost::interprocess::vector<T,A>' being compiled with [ T=int, A=EventAllocator ] d:\boost_1_35_0\boost\preprocessor\iteration\detail\local.hpp(37) : while compiling class-template member function 'void boost::interprocess::detail::Ctor1Arg<T,is_iterator,P0>::construct_n(void *,size_t,size_t &)' with [ T=EventList, is_iterator=false, P0=EventAllocator ] d:\boost_1_35_0\boost\preprocessor\iteration\detail\local.hpp(37) : see reference to class template instantiation 'boost::interprocess::detail::Ctor1Arg<T,is_iterator,P0>' being compiled with [ T=EventList, is_iterator=false, P0=EventAllocator ] DataHandle.cpp(51) : see reference to function template instantiation 'T *boost::interprocess::detail::named_proxy<SegmentManager,T,is_iterator>::operator ()<EventAllocator>(const P0 &) const' being compiled with [ T=EventList, SegmentManager=boost::interprocess::segment_manager<char,boost::interprocess::rbtree_best_fit<boost::interprocess::mutex_family>,boost::interprocess::iset_index>, is_iterator=false, P0=EventAllocator ]

Eugen Stoianovici wrote:
I'm having some trouble creating a vector in a shared memory segment (compilation errors)
The code:
[...]
This compiles fine in Visual 2003 and should not be problems with other compilers. Which compiler/version are you using? #include <boost/interprocess/containers/vector.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <boost/interprocess/managed_shared_memory.hpp> int main(){ //Allocator for the event list typedef boost::interprocess::allocator <int,boost::interprocess::managed_shared_memory::segment_manager> EventAllocator; //the in memory vector of events typedef boost::interprocess::vector<int, EventAllocator> EventList; boost::interprocess::managed_shared_memory segment(boost::interprocess::open_only, "asdf"); //is it already created? EventList* pEventList = segment.find<EventList>("EVENTSEGMENT_NAME").first; } Regards, Ion

I'm sorry, as always the problem was between keyboard and chair. I forgot to include boost/interprocess/containers/vector.hpp but there was a include <vector> somewhere and the compiler got confused Thanks for your reply, Eugen Ion Gaztañaga wrote:
Eugen Stoianovici wrote:
I'm having some trouble creating a vector in a shared memory segment (compilation errors)
The code:
[...]
This compiles fine in Visual 2003 and should not be problems with other compilers. Which compiler/version are you using?
#include <boost/interprocess/containers/vector.hpp> #include <boost/interprocess/allocators/allocator.hpp> #include <boost/interprocess/managed_shared_memory.hpp>
int main(){ //Allocator for the event list typedef boost::interprocess::allocator <int,boost::interprocess::managed_shared_memory::segment_manager> EventAllocator;
//the in memory vector of events typedef boost::interprocess::vector<int, EventAllocator> EventList;
boost::interprocess::managed_shared_memory segment(boost::interprocess::open_only, "asdf"); //is it already created? EventList* pEventList = segment.find<EventList>("EVENTSEGMENT_NAME").first;
}
Regards,
Ion
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Eugen Stoianovici
-
Ion Gaztañaga