Boost包括造成严重破坏 - 但这不是Boost的错

Boost includes wreaks havoc - but it's not Boost's fault

本文关键字:Boost 这不是 的错 严重破坏 包括造      更新时间:2023-10-16

我正在将 Boost 引入我的项目中,一旦我在特定文件中包含 Boost 标头 ( #include <boost/property_tree/ptree.hpp> ),我在 boost 标头中出现错误。

以下是错误的简短片段:

1>c:boostincludeboost-1_57boostmpleval_if.hpp(28): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:boostincludeboost-1_57boostmpleval_if.hpp(28): error C2143: syntax error : missing ',' before 'sizeof'
1>c:boostincludeboost-1_57boostmpleval_if.hpp(26): error C3747: missing default template parameter : parameter 2
1>c:boostincludeboost-1_57boostmpleval_if.hpp(40): error C2974: 'boost::mpl::if_' : invalid template argument for 'T2', type expected
1>          c:boostincludeboost-1_57boostmplif.hpp(56) : see declaration of 'boost::mpl::if_'
1>          c:boostincludeboost-1_57boostmpleval_if.hpp(44) : see reference to class template instantiation 'boost::mpl::eval_if<C,__formal>' being compiled
1>c:boostincludeboost-1_57boostmpleval_if.hpp(40): error C2974: 'boost::mpl::if_' : invalid template argument for 'T3', type expected
1>          c:boostincludeboost-1_57boostmplif.hpp(56) : see declaration of 'boost::mpl::if_'
1>c:boostincludeboost-1_57boostmpleval_if.hpp(50): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:boostincludeboost-1_57boostmpleval_if.hpp(50): error C2143: syntax error : missing ',' before 'sizeof'
1>c:boostincludeboost-1_57boostmpleval_if.hpp(62): error C2974: 'boost::mpl::if_c' : invalid template argument for 'T1', type expected

我立即想到了命名空间冲突,并删除了所有using namespace std,但这并没有解决问题。我在另一个位置使用了 Boost 线程,它按预期工作(但该代码现在处于非活动状态且未构建)。

有什么提示吗?

--- 一些注意事项

  1. 在VS2013中运行

  2. 无需using namespace std即可构建和工作的代码

我唯一能想到的是,在提升头文件之前包含的一个头文件中有一个错误。我已经看到它使错误看起来像是在后面包含的标题中。您可以做的一件事可以帮助找到问题,即首先包含所有系统和提升标头,然后包含您自己的标头。