boost asio Kompilierfehler



  • Hallo.

    Ich versuch nen SSL-Socket zu verbinden. Dabei hab ich anhand des Boost-Beispiels gelehrt http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/example/ssl/client.cpp

    Ich hab dann was eigenes dazu gebaut, wobei die async_connect()-Funktion eigentlich identisch aufgerufen wird, als im Beispiel (im Konstruktor).

    Das sieht dann so aus:

    void connect(const boost::system::error_code& code, ip::tcp::resolver::iterator it, task_ptr task) override{
        boost::asio::async_connect(task->socket.lowest_layer(), it,
            boost::bind(&secure_client::handshake, this,
              boost::asio::placeholders::error, task));
    }
    

    knallt es wobei

    error: invalid operands to binary expression ('boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' and 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>')
              if (iter_ != end_)
                  ~~~~~ ^  ~~~~
    

    Ich übergebe aber wie im Beispiel einen unterliegenden Socket, einen boost::asio::ip::tcp::resolver::iterator und ne weitere Callback-Funktion. Wie im Boost-Beispiel.

    Ich kann nicht erkennen was ich am Aufruf falschmach.



  • Hi!

    Die Fehlermeldung bezieht sich anscheinend nicht auf den Code, den du gepostet hast. Es lässt sich so nur schwer sagen, was das Problem ist.



  • Hallo, ja, aber wenn ich async_connect() weglasse, dann kommen irgendwie keine Fehler dabei raus.

    Hier nochmal einen genaueren Überblick vom Code:

    template<typename T>
    class client_base{
    ...
    protected:    virtual void connect(const boost::system::error_code& , ip::tcp::resolver::iterator , task_ptr ) = 0;
    };
    
    template<typename T>
    class secure_client : public client_base<secure_task<T>>{
        using self = client_base<secure_task<T>>;
    
        void connect(const boost::system::error_code& code, ip::tcp::resolver::iterator it, typename self::task_ptr task) override{
            if(code)
                throw std::runtime_error{code.message()};
    
            self::tasks.push_back(task);
    
            boost::asio::async_connect(task->socket.lowest_layer(), it,
                boost::bind(&secure_client::handshake, this,
                  boost::asio::placeholders::error, task));
        }
    ...
    }_
    
        void handshake(const boost::system::error_code& code, typename self::task_ptr task){
    ...
        }
    

    task_ptr ist ein shared_ptr<>.
    tasks ist ein vector davon.
    Den Template hab ich lediglich für einen generischen Buffer für den Response Body.



  • Der Code enthält leider immer noch nicht die Zeile (und seinen Kontext), auf den sich die Fehlermeldung bezieht.



  • Der Code ist ziemlich groß.

    Was genau ist denn jetzt noch relevant?

    Wenn ich auf die Fehlermeldung klicke dann zeigt er in die Boost-Datei, wo der != Operator für ip::tcp::resolver::iterator scheinbar nicht definiert ist.

    Ich bekomme weitere Fehlermeldungen, die sich auf boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp> beziehen, beispielsweise dass der Postfix-Inkrement-Operator nicht definiert ist.



  • Wie lautet die vollständige Fehlermeldung? Aus welcher Boost-Funktion kommt der Fehler? Wie wird sie aufgerufen? Das sind die relevanten Informationen.



  • Hier der Kompilierlog. Ist leider ziemlich groß, aber sowas findet man so oft bei den Boost Libs. Ich kann da irgendwie schlecht rauslesen was ich falsch gemacht hab.

    Es geht halt um boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp> , was glaub ich der Iterator ist, der hier irgendwie nicht accessible zu sein scheint.

    Ich ruf sie mit async_connect() auf. Wie gesagt, ohne das gezeigte async_connect() kompiliert der Code einwandfrei.

    Header-Dateien stehen im Log.

    clang++ -c -pipe -g -std=gnu++11 -Wall -W -fPIC -DQT_QML_DEBUG -I../cppProject -I. -I/usr/lib/qt/mkspecs/linux-clang -o main.o ../cppProject/main.cpp
    ../cppProject/main.cpp:1069:55: warning: unused parameter 't' [-Wunused-parameter]
        p->callback =  [](const secure_task<std::string>& t){
                                                          ^
    In file included from ../cppProject/main.cpp:598:
    In file included from /usr/include/boost/asio.hpp:43:
    In file included from /usr/include/boost/asio/connect.hpp:823:
    /usr/include/boost/asio/impl/connect.hpp:226:21: error: invalid operands to binary expression ('boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' and 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>')
              if (iter_ != end_)
                  ~~~~~ ^  ~~~~
    /usr/include/boost/asio/impl/connect.hpp:340:3: note: in instantiation of member function 'boost::asio::detail::connect_op<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>, boost::asio::detail::default_connect_condition, boost::_bi::bind_t<void, boost::_mfi::mf3<void, client_base<secure_task<std::__cxx11::basic_string<char> > >, const boost::system::error_code &, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, std::shared_ptr<secure_task<std::__cxx11::basic_string<char> > > >, boost::_bi::list4<boost::_bi::value<client_base<secure_task<std::__cxx11::basic_string<char> > > *>, boost::arg<1> (*)(), boost::_bi::value<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >, boost::_bi::value<std::shared_ptr<secure_task<std::__cxx11::basic_string<char> > > > > > >::operator()' requested here
      detail::connect_op<Protocol, SocketService, Iterator,
      ^
    ../cppProject/main.cpp:862:13: note: in instantiation of function template specialization 'boost::asio::async_connect<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost::asio::ip::tcp>, boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>, boost::_bi::bind_t<void, boost::_mfi::mf3<void, client_base<secure_task<std::__cxx11::basic_string<char> > >, const boost::system::error_code &, boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, std::shared_ptr<secure_task<std::__cxx11::basic_string<char> > > >, boost::_bi::list4<boost::_bi::value<client_base<secure_task<std::__cxx11::basic_string<char> > > *>, boost::arg<1> (*)(), boost::_bi::value<boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp> >, boost::_bi::value<std::shared_ptr<secure_task<std::__cxx11::basic_string<char> > > > > > >' requested here
                async_connect(task->socket.lowest_layer(), curr,
                ^
    ../cppProject/main.cpp:1030:41: note: in instantiation of member function 'client_base<secure_task<std::__cxx11::basic_string<char> > >::send_request' requested here
                boost::bind(&secure_client::send_request, this, placeholders::error, ip::tcp::resolver::iterator(), task));
                                            ^
    ../cppProject/main.cpp:1021:41: note: in instantiation of member function 'secure_client<std::__cxx11::basic_string<char> >::handshake' requested here
                boost::bind(&secure_client::handshake, this,
                                            ^
    ../cppProject/main.cpp:1074:32: note: in instantiation of member function 'secure_client<std::__cxx11::basic_string<char> >::connect' requested here
        secure_client<std::string> c(service);
                                   ^
    /usr/include/boost/function/function_base.hpp:783:3: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::function_base' for 1st argument
      operator!=(const function_base& f, Functor g)
      ^
    /usr/include/boost/function/function_base.hpp:792:3: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::function_base' for 2nd argument
      operator!=(Functor g, const function_base& f)
      ^
    /usr/include/boost/function/function_base.hpp:709:13: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::function_base' for 1st argument
    inline bool operator!=(const function_base& f,
                ^
    /usr/include/boost/function/function_base.hpp:721:13: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'detail::function::useless_clear_type *' for 1st argument
    inline bool operator!=(detail::function::useless_clear_type*,
                ^
    /usr/include/boost/asio/ip/tcp.hpp:136:15: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::asio::ip::tcp' for 1st argument
      friend bool operator!=(const tcp& p1, const tcp& p2)
                  ^
    /usr/include/boost/range/iterator_range_core.hpp:594:9: note: candidate template ignored: could not match 'iterator_range' against 'basic_resolver_entry'
            operator!=( const ForwardRange& l, const iterator_range<IteratorT>& r )
            ^
    /usr/include/boost/range/iterator_range_core.hpp:661:9: note: candidate template ignored: could not match 'iterator_range' against 'basic_resolver_entry'
            operator!=( const iterator_range<Iterator1T>& l, const iterator_range<Iterator2T>& r )
            ^
    /usr/include/boost/range/iterator_range_core.hpp:671:9: note: candidate template ignored: could not match 'iterator_range' against 'basic_resolver_entry'
            operator!=( const iterator_range<IteratorT>& l, const ForwardRange& r )
            ^
    /usr/include/boost/function/function_base.hpp:820:3: note: candidate template ignored: could not match 'reference_wrapper' against 'basic_resolver_entry'
      operator!=(const function_base& f, reference_wrapper<Functor> g)
      ^
    /usr/include/boost/function/function_base.hpp:829:3: note: candidate template ignored: could not match 'reference_wrapper' against 'basic_resolver_entry'
      operator!=(reference_wrapper<Functor> g, const function_base& f)
      ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function0' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function1' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function2' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function3' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function4' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function5' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function6' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function7' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function8' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function9' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1035:8: note: candidate template ignored: could not match 'function10' against 'basic_resolver_entry'
      void operator!=(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/smart_ptr/shared_ptr.hpp:795:40: note: candidate template ignored: could not match 'shared_ptr' against 'basic_resolver_entry'
    template<class T, class U> inline bool operator!=(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT
                                           ^
    /usr/include/boost/smart_ptr/shared_ptr.hpp:823:31: note: candidate template ignored: could not match 'shared_ptr' against 'basic_resolver_entry'
    template<class T> inline bool operator!=( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
                                  ^
    /usr/include/boost/smart_ptr/shared_ptr.hpp:828:31: note: candidate template ignored: could not match 'shared_ptr' against 'basic_resolver_entry'
    template<class T> inline bool operator!=( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT
                                  ^
    In file included from ../cppProject/main.cpp:598:
    In file included from /usr/include/boost/asio.hpp:43:
    In file included from /usr/include/boost/asio/connect.hpp:823:
    /usr/include/boost/asio/impl/connect.hpp:243:21: error: invalid operands to binary expression ('boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' and 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>')
              if (iter_ == end_)
                  ~~~~~ ^  ~~~~
    /usr/include/boost/function/function_base.hpp:765:3: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::function_base' for 1st argument
      operator==(const function_base& f, Functor g)
      ^
    /usr/include/boost/function/function_base.hpp:774:3: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::function_base' for 2nd argument
      operator==(Functor g, const function_base& f)
      ^
    /usr/include/boost/function/function_base.hpp:703:13: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::function_base' for 1st argument
    inline bool operator==(const function_base& f,
                ^
    /usr/include/boost/function/function_base.hpp:715:13: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'detail::function::useless_clear_type *' for 1st argument
    inline bool operator==(detail::function::useless_clear_type*,
                ^
    /usr/include/boost/asio/ip/impl/address_v6.ipp:251:6: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::asio::ip::address_v6' for 1st argument
    bool operator==(const address_v6& a1, const address_v6& a2)
         ^
    /usr/include/boost/asio/ip/impl/address.ipp:202:6: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::asio::ip::address' for 1st argument
    bool operator==(const address& a1, const address& a2)
         ^
    /usr/include/boost/asio/ip/tcp.hpp:130:15: note: candidate function not viable: no known conversion from 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>' to 'const boost::asio::ip::tcp' for 1st argument
      friend bool operator==(const tcp& p1, const tcp& p2)
                  ^
    /usr/include/boost/range/iterator_range_core.hpp:584:9: note: candidate template ignored: could not match 'iterator_range' against 'basic_resolver_entry'
            operator==( const ForwardRange& l, const iterator_range<IteratorT>& r )
            ^
    /usr/include/boost/range/iterator_range_core.hpp:643:9: note: candidate template ignored: could not match 'iterator_range' against 'basic_resolver_entry'
            operator==( const iterator_range<Iterator1T>& l, const iterator_range<Iterator2T>& r )
            ^
    /usr/include/boost/range/iterator_range_core.hpp:653:9: note: candidate template ignored: could not match 'iterator_range' against 'basic_resolver_entry'
            operator==( const iterator_range<IteratorT>& l, const ForwardRange& r )
            ^
    /usr/include/boost/function/function_base.hpp:802:3: note: candidate template ignored: could not match 'reference_wrapper' against 'basic_resolver_entry'
      operator==(const function_base& f, reference_wrapper<Functor> g)
      ^
    /usr/include/boost/function/function_base.hpp:811:3: note: candidate template ignored: could not match 'reference_wrapper' against 'basic_resolver_entry'
      operator==(reference_wrapper<Functor> g, const function_base& f)
      ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function0' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function1' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function2' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function3' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function4' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function5' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function6' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function7' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function8' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function9' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/function/function_template.hpp:1028:8: note: candidate template ignored: could not match 'function10' against 'basic_resolver_entry'
      void operator==(const BOOST_FUNCTION_FUNCTION<
           ^
    /usr/include/boost/bind/arg.hpp:48:40: note: candidate template ignored: could not match 'arg' against 'basic_resolver_entry'
    template< int I > BOOST_CONSTEXPR bool operator==( arg<I> const &, arg<I> const & )
                                           ^
    /usr/include/boost/smart_ptr/shared_ptr.hpp:790:40: note: candidate template ignored: could not match 'shared_ptr' against 'basic_resolver_entry'
    template<class T, class U> inline bool operator==(shared_ptr<T> const & a, shared_ptr<U> const & b) BOOST_NOEXCEPT
                                           ^
    /usr/include/boost/smart_ptr/shared_ptr.hpp:813:31: note: candidate template ignored: could not match 'shared_ptr' against 'basic_resolver_entry'
    template<class T> inline bool operator==( shared_ptr<T> const & p, boost::detail::sp_nullptr_t ) BOOST_NOEXCEPT
                                  ^
    /usr/include/boost/smart_ptr/shared_ptr.hpp:818:31: note: candidate template ignored: could not match 'shared_ptr' against 'basic_resolver_entry'
    template<class T> inline bool operator==( boost::detail::sp_nullptr_t, shared_ptr<T> const & p ) BOOST_NOEXCEPT
                                  ^
    In file included from ../cppProject/main.cpp:598:
    In file included from /usr/include/boost/asio.hpp:43:
    In file included from /usr/include/boost/asio/connect.hpp:823:
    /usr/include/boost/asio/impl/connect.hpp:255:11: error: cannot increment value of type 'boost::asio::ip::basic_resolver_entry<boost::asio::ip::tcp>'
              ++iter_;
              ^ ~~~~~
    1 warning and 3 errors generated.
    make: *** [Makefile:743: main.o] Error 1
    23:23:35: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project cppProject (kit: clang)
    The kit clang has configuration issues which might be the root cause for this problem.
    When executing step "Make"
    23:23:35: Elapsed time: 00:01.
    


  • Schon gut hab den Fehler gefunden.

    Echt richtig Scheiß Fehlermeldungen.



  • Für die Zukunft: es ist immer noch unmöglich für einen außenstehenden, deinen Fehler zu sehen. Anhand der Melungen weiß ich jetzt, dass du in client_base<secure_task<>>::send_request einen falschen Bind machst. Der Code dazu fehlt aber nach wie vor. Nichts für ungut.



  • Ja genau.

    Die Fehlermeldungen lesen sich im Qt Creator echt scheiße an.


Anmelden zum Antworten