【问题标题】:Adding boost header files gives compile time errors添加 boost 头文件会导致编译时错误
【发布时间】:2020-06-01 12:28:18
【问题描述】:

当我添加头文件时

  #include <boost/fusion/adapted/struct/adapt_struct.hpp>

它给出了几个错误

error C2988: unrecognizable template declaration/definition
error C2143: syntax error: missing ';' before '<'
error C2913: explicit specialization; 'boost::type_of::id2type_impl' is not a specialization of a class template
error C2059: syntax error: '<'
error C2334: unexpected token(s) preceding '{'; skipping apparent function body

指向 typeof_impl.hpp 文件中的第 125 行。

【问题讨论】:

  • 您编译的 C++ 版本是什么?
  • @NathanOliver 版本是 c++14 。
  • 视觉工作室 2017
  • 对于本地文件使用“myfile/file.cpp”,但它应该是header ....
  • 你使用的是什么版本的 boost?它是否支持 Visual Studio 2017?我问是因为我不时看到这里有人使用 5 年前的 boost 版本。

标签: c++ boost visual-studio-2017 c++14


【解决方案1】:

不清楚你的意思是什么文件:

custom/boost_1_72_0/boost/typeof/typeof_impl.hpp
custom/boost_1_72_0/boost/typeof/msvc/typeof_impl.hpp
custom/boost_1_72_0/boost/typeof/dmc/typeof_impl.hpp

如果您的意思是 msvc/typeof_impl.hpp,那么您很可能遇到了预处理器问题(由于重新定义的预处理器令牌,源代码发生了变异)。

如果没有这样的文件,@drescherjm 的评论可能是正确的:您正在使用的那个版本中可能缺少特定的 MSVC 支持。

【讨论】:

  • 文件是“custom/boost_1_72_0/boost/typeof/msvc/typeof_impl.hpp”
【解决方案2】:

阅读drescherjm,sehe的cmets后,我更改了visual studio中的一些设置,当我将平台工具集从visual studio 2017 v(141)更改为visual studio 2015 v(140)时,程序编译成功。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-17
    • 1970-01-01
    • 2011-07-29
    • 1970-01-01
    • 1970-01-01
    • 2012-07-19
    相关资源
    最近更新 更多