c++ - 错误 C2182 : '*' : illegal use of type 'void' c:\boost_1_53_0\boost\smart_ptr\intrusive_ptr. hpp

标签 c++ visual-studio-2010 boost build-error websocket++

我正在尝试在我的 Windows 7 笔记本电脑上轻松开发一个 websocket++ 服务器(vi 还不太好,不想经常使用 ftp)。我将在最后迁移到 Ubuntu 12.10。

我正在使用 Visual C++ Win32 控制台应用程序项目。

includewebsocketpp 目录,安装boost 1.53.0 How do you install Boost.Build on Windows? , 和 included & linked boost Boost linking, Visual Studio & version control .

我正在尝试构建 print_server.cpp http://www.zaphoyd.com/websocketpp/manual/building-program-websocket

当我这样做时,我得到 Error 1 error C2182: '*' : illegal use of type 'void' c:\boost_1_53_0\boost\smart_ptr\intrusive_ptr.hpp Line:155 Column:1

boost 代码是(第二行是155):

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

为什么会出现此错误?我该如何解决?

最佳答案

这是在 VCPP 上使用 boost 进行编译时的一个已知问题。 WebSocket++ 0.3 不使用 intrusive_ptr,但它确实使用 static_pointer_cast。每个 boost 智能指针都实现了它们自己的 boost::static_pointer_cast 重载。 VCPP 在静态转换 shared_ptr<void> 时似乎无法选择正确的重载到 shared_ptr<connection_ptr> . Clang 和 GCC 都使用了正确的重载,而 VCPP 没有。我有一个演示这个问题的小演示程序,我一直想清理这个问题并询问 Stack Overflow 关于...

与此同时,一个简单的解决方法是告诉 WebSocket++ 使用 C++11 而不是 boost 智能指针。 VCPP 与 std::static_pointer_cast/std::shared_ptr 一起正常工作。每http://www.zaphoyd.com/websocketpp/manual/reference/cpp11-support定义 _WEBSOCKETPP_CPP11_MEMORY_在包含 WebSocket++ header 之前将完成此操作。我已经测试了 VCPP2010 的 C++11 实现 <memory>它实现了 WebSocket++ 所需的一切。

关于c++ - 错误 C2182 : '*' : illegal use of type 'void' c:\boost_1_53_0\boost\smart_ptr\intrusive_ptr. hpp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15695972/

相关文章:

c++ - 未提供 .lib 时如何在 visual studio 2010 中添加和使用第三方 .dll

c++ - 使用 phoenix 构造时调用析构函数

C++ Boost.Python : 2 problems

c++ - 如何在可编辑的 QTableWidgetItem 中捕捉按键?

c++ - 在VS2010中排除一个系统头文件

c# - 使用 VS2010 运行 StyleCop 时出现 CA2000 Microsoft.Reliability 错误

.net - 按 ctrl+space 时 Visual Studio 显示文档

c++ - 在 Boost 中同步线程

c++ - 平方差的数值精度

c++ - leveldb 中的整数值