Compling error on ubuntu: invalid initialization of non-const reference
ptx9363 opened this issue · comments
Hello, while i'm compiling this project, i have encountered following errors:
vanilla-rtb/rtb/messaging/serialization.hpp:222:28: error: invalid initialization of non-const reference of type ‘long unsigned int&’ from an rvalue of type ‘jsonv::detail::string_view::size_type {aka long unsigned int}’
ar & value.size();
^
In file included from /usr/include/boost/archive/detail/common_oarchive.hpp:22:0,
from /usr/include/boost/archive/basic_binary_oarchive.hpp:34,
from /usr/include/boost/archive/binary_oarchive_impl.hpp:23,
from /usr/include/boost/archive/binary_oarchive.hpp:21,
from /home/pantianxiang/vanilla-rtb/rtb/messaging/communicator.hpp:31,
from /home/pantianxiang/vanilla-rtb/examples/exchange_handler_test.cpp:13:
/usr/include/boost/archive/detail/interface_oarchive.hpp:69:15: note: initializing argument 1 of ‘Archive& boost::archive::detail::interface_oarchive<Archive>::operator&(T&) [with T = long unsigned int; Archive = boost::archive::binary_oarchive]’
Archive & operator&(T & t){
^
In file included from /usr/include/c++/5/algorithm:62:0,
from /usr/include/boost/smart_ptr/shared_ptr.hpp:37,
from /usr/include/boost/log/core/core.hpp:19,
from /usr/include/boost/log/sources/basic_logger.hpp:37,
from /usr/include/boost/log/sources/severity_logger.hpp:23,
from /usr/include/boost/log/trivial.hpp:22,
from /home/pantianxiang/vanilla-rtb/examples/exchange_handler_test.cpp:2:
/usr/include/c++/5/bits/stl_algo.h:3761:5: error: ‘_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = const char*; _Funct = boost::serialization::save(Archive&, const string_view&, unsigned int) [with Archive = boost::archive::binary_oarchive; jsonv::string_view = jsonv::detail::string_view]::<lambda(char)>]’, declared using local type ‘boost::serialization::save(Archive&, const string_view&, unsigned int) [with Archive = boost::archive::binary_oarchive; jsonv::string_view = jsonv::detail::string_view]::<lambda(char)>’, is used but never defined [-fpermissive]
for_each(_InputIterator __first, _InputIterator __last, _Function __f)
^
examples/CMakeFiles/exchange_handler_test.dir/build.make:62: recipe for target 'examples/CMakeFiles/exchange_handler_test.dir/exchange_handler_test.cpp.o' failed
Seem like the initialization od value.size() is invalid, yet i'm not aware how to initialize it correctly. Looking forward for your help.
Please let us know version of
- gcc
- boost
- cmake
Hi ptx9363,
We have discovered an issue with boost versions < 1.60 as it declared operator with reference and not
const reference
Archive & operator&(T & t)
And it's been a known issue in boost.serialization for a while and it's been fixed in 1.60 onward
Archive & operator&(const T & t)
Please upgrade your boost to >= 1.60 .
I am going to close this issue as resolved by pull request #54
If after upgrade it does not work for you please re-open this issue.