Error: no matching function for call to

I am working on examples of the book and I came across an error which I doubt I can find the origin of the issue all by myself. The error occurs when I try to use function close() inside a function. I am doing some socket operation and after that I try to close the socket where I get this error :

error: no matching function for call to ‘ExampleWindow::close(int&)’

Any idea what might be causing this ?

This looks like C++. Your class has(/inherits) a close(int&) function that has priority in code inside a member method (since there is the implicit this thing) over functions outside (the close() for sockets), so you want to use ::close(...); instead (that initial :: tells the compiler to start looking from the “global” scope).

You may want to consider GIO Sockets or SocketClient over doing them yourself if you like, assuming the book isn’t about socket programming.

1 Like
::close(int sock)

solved the issue. I coudn’t see where the “close” inherits from in the compiling process. Thank you for your answer and solution. Cheers !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.