【发布时间】:2016-05-19 03:49:10
【问题描述】:
我是使用 boost 库的初学者。
#include<boost/version.hpp>
#include <iostream>
using namespace std;
int main() {
cout << "My first boost program with version:" <<BOOST_LIB_VERSION<< endl;
return 0;
}
以上代码返回时没有编译或执行错误。
输出:
My first boost program with version:1_33_1
但是当我在 .cpp 文件中包含 boost/algorithm/string/trim.hpp 时,我遇到了编译错误。
#include<boost/version.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <iostream>
using namespace std;
int main() {
cout << "My first boost program with version:" <<BOOST_LIB_VERSION<< endl;
return 0;
}
at this point in file device_tml line 35, external location: /usr/include/boost/range/detail/implementation_help.hpp C/C++ Problem
at this point in file device_tml line 41, external location: /usr/include/boost/range/detail/implementation_help.hpp C/C++ Problem
expected ';' before 'str_end' device_tml line 57, external location: /usr/include/boost/range/detail/implementation_help.hpp C/C++ Problem
expected primary-expression before ',' token device_tml line 57, external location: /usr/include/boost/range/detail/implementation_help.hpp C/C++ Problem
expected primary-expression before ';' token device_tml line 111, external location: /usr/include/boost/range/detail/implementation_help.hpp C/C++ Problem
expected primary-expression before ')' token device_tml line 57, external location: /usr/include/boost/range/detail/implementation_help.hpp C/C++ Problem
expected primary-expression before '*' token device_tml line 57, external location: /usr/include/boost/range/detail/implementation_help.hpp C/C++ Problem
no matching function for call to 'str_end()' device_tml line 103, external location: /usr/include/boost/range/end.hpp C/C++ Problem
no matching function for call to 'str_end()' device_tml line 108, external location: /usr/include/boost/range/end.hpp C/C++ Problem
no matching function for call to 'str_end()' device_tml line 111, external location: /usr/include/boost/range/detail/implementation_help.hpp C/C++ Problem
no matching function for call to 'str_end()' device_tml line 113, external location: /usr/include/boost/range/end.hpp C/C++ Problem
no matching function for call to 'str_end()' device_tml line 98, external location: /usr/include/boost/range/end.hpp C/C++ Problem
return-statement with no value, in function returning 'char*' device_tml line 103, external location: /usr/include/boost/range/begin.hpp C/C++ Problem
return-statement with no value, in function returning 'const char*' device_tml line 98, external location: /usr/include/boost/range/begin.hpp C/C++ Problem
return-statement with no value, in function returning 'const wchar_t*' device_tml line 108, external location: /usr/include/boost/range/begin.hpp C/C++ Problem
return-statement with no value, in function returning 'wchar_t*' device_tml line 113, external location: /usr/include/boost/range/begin.hpp C/C++ Problem
too few arguments to function 'size_t strlen(const char*)' device_tml line 243, external location: /usr/include/string.h C/C++ Problem
too few arguments to function 'size_t wcslen(const wchar_t*)' device_tml line 243, external location: /usr/include/wchar.h C/C++ Problem
const wchar_t* boost::range_detail::str_end(const wchar_t*, const wchar_t*) device_tml line 39, external location: /usr/include/boost/range/detail/implementation_help.hpp C/C++ Problem
编译器版本
gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)
编译器选项
-O0 -g3 -Wall -c -fmessage-length=0 -fpic -o
【问题讨论】:
-
这看起来是个有趣的问题,但请您插入错误消息的文本而不是屏幕截图,以便我们看到完整的描述。还请告诉我们编译器版本和编译器标志,因为这也可能有用。
-
如果我正在阅读文档,那么 boost 1.33 已经 11 岁了:它可能只是与现代编译器不兼容。您是否尝试过更新版本的 boost?
-
我刚刚用当前的 boost(1.61 开发版本)尝试了这个,它编译时没有错误。
-
我没有尝试使用新版本的 boost,因为我没有权限在我的工作计算机上安装。
-
他使用的 @MarkB gcc 4.1.2 或多或少与 boost 1.33 一样古老