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

二次信任 提交于 2021-01-28 05:46:28

问题


I am introducing Boost into my project and as soon as I include Boost headers (#include <boost/property_tree/ptree.hpp>) in a particular file I get errors in the boost headers.

Here is a short snippet of the errors:

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

I immediately thought about namespace collision and I removed all using namespace std, but this didn't solve the problem. I have used Boost threads in another location and it worked as expected (but that code is now inactive and not being built).

Any hints?

--- Some notes

  1. Running in VS2013

  2. Code without using namespace std builds and works


回答1:


The only thing I can think of is there is an error in one of your header files that is being included before a boost header. I have seen that make it look like the error is in the header included after. One thing you might be able to do to help find the problem is to include all system and boost headers first and then include your own headers.



来源:https://stackoverflow.com/questions/28947409/boost-includes-wreaks-havoc-but-its-not-boosts-fault

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!