添加boost头文件会产生编译时错误

Adding boost header files gives compile time errors

当我添加头文件时

  #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 行。

不清楚你指的是什么文件:

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 支持。

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