Ste*_*gen 7 c++ macos makefile configure c++11
我正在尝试从源代码编译libgtextutils(fastxtoolkit所需).'./configure'命令运行良好,但随后的'make'命令会产生一个我无法解决的错误.
text_line_reader.cpp: In member function ‘bool TextLineReader::next_line()’:
text_line_reader.cpp:47:9: error: cannot convert ‘std::istream {aka std::basic_istream<char>}’ to ‘bool’ in return
return input_stream ;
^~~~~~~~~~~~
make[3]: *** [text_line_reader.lo] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
Run Code Online (Sandbox Code Playgroud)
我在Mac上,OSX 10.11.6(英特尔)
任何可能解决此问题的建议都受到高度赞赏.
Jon*_*ely 15
请参阅移植到GCC 6指南,该指南将此作为您必须处理的更改之一,因为GCC 6默认为C++ 14模式而不是C++ 03模式:
无法将'std :: ostream'转换为'bool'
从C++ 11开始,iostream类不再可以隐式转换为,
void*
因此它不再有效:Run Code Online (Sandbox Code Playgroud)bool valid(std::ostream& os) { return os; }
必须更改此类代码才能将iostream对象明确转换为bool,例如
return (bool)os;
或return static_cast<bool>(os);
另一种选择是-std=c++03
在编译器标志中明确使用C++ 03模式进行编译,但最好修复代码.上面给出的修复将使代码与任何C++版本兼容.
归档时间: |
|
查看次数: |
5934 次 |
最近记录: |