Search code examples
c++visual-studio-2010boostbuild-errorwebsocket++

error C2182: '*' : illegal use of type 'void' c:\boost_1_53_0\boost\smart_ptr\intrusive_ptr.hpp


I'm trying to develop a websocket++ server on my windows 7 laptop for ease (not good with vi yet, don't want to constantly ftp). I will move to Ubuntu 12.10 at the end.

I'm using a Visual C++ Win32 Console Application project.

I've included the websocketpp directory, installed boost 1.53.0 How do you install Boost.Build on Windows?, and included & linked boost Boost linking, Visual Studio & version control.

I'm trying to build print_server.cpp http://www.zaphoyd.com/websocketpp/manual/building-program-websocket

When I do, I get Error 1 error C2182: '*' : illegal use of type 'void' c:\boost_1_53_0\boost\smart_ptr\intrusive_ptr.hpp Line:155 Column:1

The boost code is (second line is 155):

T & operator*() const
{
    BOOST_ASSERT( px != 0 );
    return *px;
}

Why am I getting this error? How do I fix it?


Solution

  • This is a known issue when compiling using boost on VCPP. WebSocket++ 0.3 does not use intrusive_ptr, but it does use static_pointer_cast. Each boost smart pointer implements their own overload of boost::static_pointer_cast. VCPP appears to be unable to choose the correct overload when static casting a shared_ptr<void> to a shared_ptr<connection_ptr>. Clang and GCC both use the correct overload, VCPP doesn't. I have a little demo program that demonstrates this issue that I've been meaning to clean up and ask Stack Overflow about...

    A simple fix in the meantime is to tell WebSocket++ to use C++11 rather than boost smart pointers. VCPP works correctly with std::static_pointer_cast / std::shared_ptr. Per http://www.zaphoyd.com/websocketpp/manual/reference/cpp11-support defining _WEBSOCKETPP_CPP11_MEMORY_ before including WebSocket++ headers will accomplish this. I've tested VCPP2010's implementation of C++11 <memory> and it implements everything that WebSocket++ needs.