ArcticaProject / nx-libs

nx-libs
Other
121 stars 39 forks source link

compilation of nx-libs fails on OpenBSD clang compiler #1044

Open sandeep-gh opened 2 years ago

sandeep-gh commented 2 years ago

Using OpenBSD clang version 11.1.0 compiler for Target: aarch64-unknown-openbsd7. to compile nx-libs. It fails to compile due to type mismatch I guess. Is there a workaround/easy fix.


  if (bind(newFD, addr, addrlen) == -1)
      ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~
/usr/include/c++/v1/system_error:390: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
^
/usr/include/c++/v1/system_error:397: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_condition& __y) _NOEXCEPT
^
/usr/include/c++/v1/system_error:405:1: note: candidate function not viable: no known conversion from '__bind<int &, sockaddr *&, unsigned int &>' to 'const std::__1::error_condition' for 1st argument
operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT
^
/usr/include/c++/v1/system_error:412:1: note: candidate function not viable: no known conversion from '__bind<int &, sockaddr *&, unsigned int &>' to 'const std::__1::error_condition' for 1st argument
operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT
^
/usr/include/c++/v1/utility:576:1: note: candidate template ignored: could not match 'pair' against '__bind'
operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)```
uli42 commented 2 years ago

Hmm, we are successfully compiling using clang in GitHub actions. In what file do see this line?

Uli

sandeep-gh @.***> schrieb am Do., 24. März 2022, 07:40:

Using OpenBSD clang version 11.1.0 compiler for Target: aarch64-unknown-openbsd7. to compile nx-libs. It fails to compile due to type mismatch I guess. Is there a workaround/easy fix.

if (bind(newFD, addr, addrlen) == -1)


/usr/include/c++/v1/system_error:390: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
^
/usr/include/c++/v1/system_error:397: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_condition& __y) _NOEXCEPT
^
/usr/include/c++/v1/system_error:405:1: note: candidate function not viable: no known conversion from '__bind<int &, sockaddr *&, unsigned int &>' to 'const std::__1::error_condition' for 1st argument
operator==(const error_condition& __x, const error_code& __y) _NOEXCEPT
^
/usr/include/c++/v1/system_error:412:1: note: candidate function not viable: no known conversion from '__bind<int &, sockaddr *&, unsigned int &>' to 'const std::__1::error_condition' for 1st argument
operator==(const error_condition& __x, const error_condition& __y) _NOEXCEPT
^
/usr/include/c++/v1/utility:576:1: note: candidate template ignored: could not match 'pair' against '__bind'
operator==(const pair<_T1,_T2>& __x, const pair<_T1,_T2>& __y)```

—
Reply to this email directly, view it on GitHub
<https://github.com/ArcticaProject/nx-libs/issues/1044>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQHBZB2FC36WRAZ34RH533VBQE5DANCNFSM5RQEWHIQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
sandeep-gh commented 2 years ago

My bad, didn't copy the file name error message. Its in nxcomp/src/Loop.cpp.

Loop.cpp:4224:34: error: invalid operands to binary expression ('__bind<int &, sockaddr *&, unsigned int &>' and 'int')
ryandesign commented 1 week ago

This problem also prevents building on macOS; here is the MacPorts bug report: https://trac.macports.org/ticket/71014

ryandesign commented 1 week ago

This answer explains the problem:

Your code is trying to call the C++ std::bind() function, not the socket bind() function. This is likely due to a using namespace std; statement in your code.

I see this here:

https://github.com/ArcticaProject/nx-libs/blob/b6fae31a27591c1e04fdf74ec31e7dc95ba77fc5/nxcomp/src/Types.h#L29

and here:

https://github.com/ArcticaProject/nx-libs/blob/b6fae31a27591c1e04fdf74ec31e7dc95ba77fc5/nxcomp/src/Misc.h#L41

and here:

https://github.com/ArcticaProject/nx-libs/blob/b6fae31a27591c1e04fdf74ec31e7dc95ba77fc5/nxcompshad/src/Misc.h#L34

These should be removed and any references to std funtions fully qualified.

To ensure the correct function is being called, you can either get rid of the using statement, or else qualify the call as using the function from the global namespace:

This does work around the problem, but is not the fix I recommend:

--- nxcomp/src/Loop.cpp.orig    2019-08-27 08:46:39.000000000 -0500
+++ nxcomp/src/Loop.cpp 2024-11-22 20:22:54.000000000 -0600
@@ -4221,7 +4221,7 @@
       goto SetupSocketError;
     }

-  if (bind(newFD, addr, addrlen) == -1)
+  if (::bind(newFD, addr, addrlen) == -1)
   {
     nxfatal << "Loop: PANIC! Call to bind failed for " << label
             << ". Error is " << EGET()