views:

238

answers:

2

Good day.

I have a Types.hpp file in my project. And within it i have:

....    
namespace RC 
{
 .....
 .....

 struct ViewSettings
 {
  ....
 };

 .....
}

In the Server.cpp file I'm including this Types.hpp file, and i have there:

class Session
{
 .....

 RC::ViewSettings tmp;
 boost::asio::async_read(socket_, boost::asio::buffer(&tmp, sizeof(RC::ViewSettings)), 
                         boost::bind(&Session::Finish_Reading_Data, shared_from_this(), boost::asio::placeholders::error));

 .....
}

And during the compilation i have an errors:

 error C2825: 'F': must be a class or namespace when followed by '::'
 : see reference to class template instantiation 'boost::_bi::result_traits<R,F>' 

 being compiled with
 [
  R=boost::_bi::unspecified,
  F=void (__thiscall Session::* )(void)
 ]

 : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' 
 being compiled with
 [
  R=boost::_bi::unspecified,
  F=void (__thiscall Session::* )(void),
  L=boost::_bi::list2<boost::_bi::value<boost::shared_ptr<Session>>,boost::arg<1>>
 ]

 error C2039: 'result_type' : is not a member of '`global namespace''

And the code like this works in proper way:

   int w; 
   boost::asio::async_read(socket_, boost::asio::buffer(&w, sizeof(int)), 
                        boost::bind(&Session::Handle_Read_Width, shared_from_this(), boost::asio::placeholders::error));

Please, help. What's the problem here? Thanks in advance.

A: 

You are trying to transfer a struct, not just a simple type. That's why it works with int, and won't work with the struct.

I think this is in the area of serialization, so i think you will need boost.serialization.

http://www.boost.org/doc/libs/1_43_0/doc/html/boost_asio/examples.html Check this serialization example, maybe that will help you out.

Budzoli
A: 

You need to inherit Session from boost::enable_shared_from_this<Session>.

ergosys