BOOST与C++11冲突的问题

原来工程在VS2008下运行,加载的是1.48版本的boost库,在VS2015中出现以下错误:

3>D:\boostlib\boost_1_46_1\boost/thread/xtime.hpp(23): error C2059:
语法错误:“常量” 1>D:\boostlib\boost_1_46_1\boost/thread/xtime.hpp(31): error
C2143: 语法错误: 缺少“;”(在“}”的前面)
1>D:\boostlib\boost_1_46_1\boost/thread/xtime.hpp(46): error C2833:
“operator system_time”不是可识别的运算符或类型
1>D:\boostlib\boost_1_46_1\boost/thread/xtime.hpp(46): error C2059:
语法错误:“newline” 1>D:\boostlib\boost_1_46_1\boost/thread/xtime.hpp(47):
error C2334: “{”的前面有意外标记;跳过明显的函数体
1>D:\boostlib\boost_1_46_1\boost/thread/xtime.hpp(73): error C3861:
“get_system_time”: 找不到标识符
1>D:\boostlib\boost_1_46_1\boost/thread/xtime.hpp(88): error C2059:
语法错误:“}” 1>D:\boostlib\boost_1_46_1\boost/thread/xtime.hpp(88): error
C2143: 语法错误: 缺少“;”(在“}”的前面)
1>d:\boostlib\boost_1_46_1\boost\thread\win32\basic_timed_mutex.hpp(22):
error C2143: 语法错误: 缺少“;”(在“{”的前面)
1>d:\boostlib\boost_1_46_1\boost\thread\win32\basic_timed_mutex.hpp(22):
error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>D:\boostlib\boost_1_46_1\boost/thread/win32/mutex.hpp(19): error
C2039: “basic_timed_mutex”: 不是“boost::detail”的成员

其原因是C++与低版本的boost库不兼容,:
If you’re getting syntax errors when using Boost, you may need to compile your code with -std=c++11.
The TIME_UTC issue you might have read about is a side effect of using c++11. TIME_UTC is now defined as a macro in c++11, so you will need to either replace all instances of TIME_UTC with TIME_UTC_, or just use a newer (1.50.0+) version of Boost where this has been fixed already.
See: https://svn.boost.org/trac10/ticket/6940

将工程里面的boost版本改为1.68即可解决该问题。

发布了37 篇原创文章 · 获赞 33 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/xu_fengyu/article/details/89605334