Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sandeep-gh opened this issue Mar 24, 2022 · 4 comments
Open

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

sandeep-gh opened this issue Mar 24, 2022 · 4 comments
Assignees

Comments

@sandeep-gh
Copy link

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
Copy link
Member

uli42 commented Mar 24, 2022 via email

@sandeep-gh
Copy link
Author

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
Copy link

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

@ryandesign
Copy link

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:

using namespace std;

and here:

using namespace std;

and here:

using namespace std;

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants