redboltz/mqtt_cpp

boost-errors when compiling library

bgewehr opened this issue · 7 comments

Hi!

I want to use this library for making the ems-collector able to send and receive MQTT.

The compiler throws errors like this:

MqttAdapter.cpp:41:22:   required from here
/usr/include/boost/multi_index/composite_key.hpp:460:53: error: no match for call to ‘(const std::less<short unsigned int>) (const std::tuple<short unsigned int, unsigned char>&, short unsigned int)’
     if(comp.get_head()(vc.get_head(),c.get_head()(v)))return true;
                                                     ^
In file included from /usr/include/c++/4.9/string:48:0,
                 from /usr/include/c++/4.9/random:40,
                 from /usr/include/c++/4.9/bits/stl_algo.h:66,
                 from /usr/include/c++/4.9/algorithm:62,
                 from MqttAdapter.cpp:20:
/usr/include/c++/4.9/bits/stl_function.h:367:12: note: candidate is:
     struct less : public binary_function<_Tp, _Tp, bool>
            ^
/usr/include/c++/4.9/bits/stl_function.h:370:7: note: bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = short unsigned int]
       operator()(const _Tp& __x, const _Tp& __y) const
       ^
/usr/include/c++/4.9/bits/stl_function.h:370:7: note:   no known conversion for argument 1 from ‘const std::tuple<short unsigned int, unsigned char>’ to ‘const short unsigned int&’
In file included from ../../mqtt_client_cpp/include/mqtt/client.hpp:24:0,
                 from ../../mqtt_client_cpp/include/mqtt_client_cpp.hpp:8,
                 from MqttAdapter.h:28,
                 from MqttAdapter.cpp:22:
/usr/include/boost/multi_index/composite_key.hpp:461:53: error: no match for call to ‘(const std::less<short unsigned int>) (short unsigned int, const std::tuple<short unsigned int, unsigned char>&)’
     if(comp.get_head()(c.get_head()(v),vc.get_head()))return false;
                                                     ^
In file included from /usr/include/c++/4.9/string:48:0,
                 from /usr/include/c++/4.9/random:40,
                 from /usr/include/c++/4.9/bits/stl_algo.h:66,
                 from /usr/include/c++/4.9/algorithm:62,
                 from MqttAdapter.cpp:20:
/usr/include/c++/4.9/bits/stl_function.h:367:12: note: candidate is:
     struct less : public binary_function<_Tp, _Tp, bool>
            ^
/usr/include/c++/4.9/bits/stl_function.h:370:7: note: bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = short unsigned int]
       operator()(const _Tp& __x, const _Tp& __y) const
       ^
/usr/include/c++/4.9/bits/stl_function.h:370:7: note:   no known conversion for argument 2 from ‘const std::tuple<short unsigned int, unsigned char>’ to ‘const short unsigned int&’
Makefile:49: recipe for target 'MqttAdapter.o' failed
make: *** [MqttAdapter.o] Error 1
bananapi@fhem:/home/bananapi/ems-collector/collector$

I have discussed the issue with the author of ems-collector, but without success:
maniac103/ems-collector#18

Can you give me the right hint to resolve that?

My -std=c++14 was on -std=c++1y and that did not cause the errors. Still investigating.

It seems that the error is caused by https://svn.boost.org/trac/boost/ticket/10315

It is fixed as boostorg/multi_index@6d6bb75

Which version of the boost library are you using? If it is 1.55 or older, please update 1.57 or newer.

The standard library is 1.55 in Debian Linux
https://packages.debian.org/jessie/libboost-all-dev

Thanks, redboltz. I'll update my readme accordingly. It would be great if you could update your readme to list the requirements of boost 1.57 and c++14 (which isn't bitfield only anymore, it's also required for auto in lambda parameters).

Compile worked with c++1y also

@maniac103 , I updated README.md. Also I removed generic lambda from the library code.
I close the issue. Thank you for your cooperation.

If there are any problems, please reopen the issue.

I can confirm the library compiles fine again with GCC and -std=c++0x. Thanks!