I'm trying to compile libgtextutils (required by the fastxtoolkit) from source. The './configure' command runs nicely, however subsequent 'make' command produces an error that I cannot resolve.
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
I'm on a Mac, OSX 10.11.6 (Intel)
Any suggestions that might solve this are highly appreciated.
See the Porting to GCC 6 guide, which documents this as one of the changes you must deal with due to GCC 6 defaulting to C++14 mode instead of C++03 mode:
Cannot convert 'std::ostream' to 'bool'
As of C++11, iostream classes are no longer implicitly convertible to
void*
so it is no longer valid to do something like:bool valid(std::ostream& os) { return os; }
Such code must be changed to convert the iostream object to bool explicitly, e.g.
return (bool)os;
orreturn static_cast<bool>(os);
Another option is to explicitly use -std=c++03
in your compiler flags to compile in C++03 mode, but it's better to fix the code. The fixes given above will make the code compatible with any C++ version.
Another option is to override the C++ flags in the make command:
make CXXFLAGS='-std=c++03 -O1'
As noted above, fastx will also have a compilation error but it will compile if you pass it
make CXXFLAGS=-O1
.
This is because of using a newer version of gcc compiler (C++11).
Use static_cast<bool>()
to resolve the issue.
example: change
success = move_group.move();
to
success = static_cast<bool>(move_group.move());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With