You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building hokuyoaist with a C++11 compiler, there are a lot of errors of the following variety:
/home/rich/fedora/hokuyoaist/hokuyoaist-b87a88aa66853d3c9d901d4e6be729c5fe69aae0/src/hokuyo_errors.cpp: In member function ‘virtual const char* hokuyoaist::BaseError::what() const’:
/home/rich/fedora/hokuyoaist/hokuyoaist-b87a88aa66853d3c9d901d4e6be729c5fe69aae0/src/hokuyo_errors.cpp:386:8: error: no match for ‘operator<<’ (operand types are ‘const stringstream {aka const std::__cxx11::basic_stringstream<char>}’ and ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’)
ss << std::string(error_type_, sizeof(error_type_)) << " (" << desc_code_ << "): " <<
~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/6.1.1/istream:39:0,
from /usr/include/c++/6.1.1/sstream:38,
from /home/rich/fedora/hokuyoaist/hokuyoaist-b87a88aa66853d3c9d901d4e6be729c5fe69aae0/include/hokuyoaist/hokuyo_errors.h:32,
from /home/rich/fedora/hokuyoaist/hokuyoaist-b87a88aa66853d3c9d901d4e6be729c5fe69aae0/src/hokuyo_errors.cpp:29:
/usr/include/c++/6.1.1/ostream:108:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
operator<<(__ostream_type& (*__pf)(__ostream_type&))
^~~~~~~~
/usr/include/c++/6.1.1/ostream:108:7: note: no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&) {aka std::basic_ostream<char>& (*)(std::basic_ostream<char>&)}’
/usr/include/c++/6.1.1/ostream:117:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>; std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]
operator<<(__ios_type& (*__pf)(__ios_type&))
^~~~~~~~
/usr/include/c++/6.1.1/ostream:117:7: note: no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&) {aka std::basic_ios<char>& (*)(std::basic_ios<char>&)}’
/usr/include/c++/6.1.1/ostream:127:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
operator<<(ios_base& (*__pf) (ios_base&))
^~~~~~~~
/usr/include/c++/6.1.1/ostream:127:7: note: no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘std::ios_base& (*)(std::ios_base&)’
/usr/include/c++/6.1.1/ostream:166:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
operator<<(long __n)
^~~~~~~~
/usr/include/c++/6.1.1/ostream:166:7: note: no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘long int’
/usr/include/c++/6.1.1/ostream:170:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
operator<<(unsigned long __n)
^~~~~~~~
/usr/include/c++/6.1.1/ostream:170:7: note: no known conversion for argument 1 from ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ to ‘long unsigned int’
/usr/include/c++/6.1.1/ostream:174:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>]
operator<<(bool __n)
^~~~~~~~
...
I think the root cause is that issue #6 changed the what() function prototype for the exceptions in hokuyo_exception to be a const function as required by c++11 std::exception::what(). However, the function body is not const, as each of the what() functions modify the member std::stringstream ss variable.
To fix this, it seems like the error description that is being built in what() should be built in the exception constructor, and stored in ss_str. Then the what() function can just return ss_str.c_str(). Doing that could allow you to remove the stringstream ss from the class entirely in favor of a temporary stringstream in each constructor.
The text was updated successfully, but these errors were encountered:
When building hokuyoaist with a C++11 compiler, there are a lot of errors of the following variety:
I think the root cause is that issue #6 changed the what() function prototype for the exceptions in hokuyo_exception to be a const function as required by c++11 std::exception::what(). However, the function body is not const, as each of the what() functions modify the member
std::stringstream ss
variable.To fix this, it seems like the error description that is being built in
what()
should be built in the exception constructor, and stored inss_str
. Then thewhat()
function can just returnss_str.c_str()
. Doing that could allow you to remove the stringstreamss
from the class entirely in favor of a temporary stringstream in each constructor.The text was updated successfully, but these errors were encountered: