-2

How do i rewrite next sources properly? It is part of GLib-powered IRC-bot. Compiler crashes with the next error:

src/irc.cpp:20:9: error: cannot call member function ‘Glib::ListHandle<Glib::RefPtr<Gio::InetAddress> > Gio::Resolver::lookup_by_name(const Glib::ustring&, const Glib::RefPtr<Gio::Cancellable>&)’ without object
     ),

Sources:

#include "includes.hpp" // Just including all the files

Glib::RefPtr<Gio::Socket> ircSock; // Our socket

void ircInit() { // Init-function
  try {
    ircSock = Gio::Socket::create( // Creating socket
      Gio::SocketFamily::SOCKET_FAMILY_IPV4,
      Gio::SocketType::SOCKET_TYPE_STREAM,
      Gio::SocketProtocol::SOCKET_PROTOCOL_TCP
    );

    ircSock->connect( // Problematic code
      Gio::InetSocketAddress::create(
        Gio::Resolver::lookup_by_name(
          "irc.freenode.net", // For-example
          Gio::Cancellable::create()
        ),
        6667
      ),
      Gio::Cancellable::create()
    );
  } catch(const Glib::Error& e) {
    std::cerr << "IRC: Error: " << e.what() << std::endl; // Error-reporting
  }
}
Starl1ght
  • 4,422
  • 1
  • 21
  • 49
handicraftsman
  • 181
  • 1
  • 13

1 Answers1

3

According to documentation, this is member function, so, you need constructed object to call it, while you are trying to call it like it is static function.

Correct fix would be to create Gio::Resolver object, and call this method on created object.

Starl1ght
  • 4,422
  • 1
  • 21
  • 49
  • `src/irc.cpp:19:18: error: request for member ‘lookup_by_name’ in ‘resolver’, which is of non-class type ‘Gio::Resolver()’` (sorry, i am new to C++. Current ver: [here](http://hastebin.com/sasezeroju.php) – handicraftsman Nov 30 '16 at 16:16