[Boost-users] Boost::interprocess sharing string

341 views
Skip to first unread message

Federico Golfrè Andreasi

unread,
Jan 19, 2009, 11:42:37 AM1/19/09
to boost...@lists.boost.org
Hi !

    I have a problem sharing a string within a shared memory segment using named objects. (Boost.interporcess 1.36.0)

I attach here the code of the two programs: one writes the string and the other read it.
In the reader a segmentation fault is throw.

Where am I wrong?
Thank you very much

Federico
writer.cpp
reader.cpp

Steven Watanabe

unread,
Jan 19, 2009, 12:54:29 PM1/19/09
to boost...@lists.boost.org
AMDG

Federico Golfrè Andreasi wrote:
> I have a problem sharing a string within a shared memory segment
> using named objects. (Boost.interporcess 1.36.0)
>
> I attach here the code of the two programs: one writes the string and
> the other read it.
> In the reader a segmentation fault is throw.
>
> Where am I wrong?

You need to use boost::interprocess::basic_string with an appropriate
allocator
instead of std::string.
http://www.boost.org/doc/html/interprocess/allocators_containers.html#interprocess.allocators_containers.containers_explained

In Christ,
Steven Watanabe

_______________________________________________
Boost-users mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Reply all
Reply to author
Forward
0 new messages