Trying to compile the following code using clang++ version 6.0 with the -std=c++17
flag:
if (bind(ssock, res->ai_addr, res->ai_addrlen) != 0)
{
return -1;
}
I get the following error:
.../udt4/app/test.cpp:90:51: error: invalid operands
to binary expression ('__bind<int &, sockaddr *&, unsigned int &>' and
'int')
if (bind(ssock, res->ai_addr, res->ai_addrlen) != 0)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
/usr/include/c++/v1/system_error:587:1: note: candidate function not viable: no
known conversion from '__bind<int &, sockaddr *&, unsigned int &>' to
'const std::__1::error_code' for 1st argument
operator!=(const error_code& __x, const error_code& __y) _NOEXCEPT
....
Somehow, the perfectly standard function bind(2)
seems to have gotten redeclared as something returning an error_code
instead of the good old int
.
What's going on? How do I solve this nicely -- and keep the code compilable with earlier compilers?