c++ - How to distinguish between bind() in sys/sockets.h and std::bind? -
i'm using g++ 4.6.0 compile c++ code compiled in earlier versions.
if ( bind(icontrol, (struct sockaddr *) &sa, sizeof(sa)) == -1) throw runtime_error ("bind");
where icontrol socket, , sa struct sockaddr_in
.
however, in g++ 4.6 following error:
comms.cpp:93:66: error: no match ‘operator==’ in ‘std::bind(_functor&&, _argtypes&& ...) [with _functor = int&, _argtypes = {sockaddr*, long unsigned int}, typename std::_bind_helper<_functor, _argtypes>::type = std::_bind<int(sockaddr*, long unsigned int)>]((* &((sockaddr*)(& sa))), (* &16ul)) == -0x00000000000000001’
comms.cpp:93:66: note: candidates are:
followed page , half of possible candidates.
it appears mixing bind function in sys/sockets.h
std::bind in functional
. how disambiguate 2 without rewriting whole source file remove using namespace std
?
qualify global: ::bind(...)
(and make sure have right headers included).
edit: (i got idea @bo persson's comment) solid option change using namespace std;
several using <thing>
like:
using std::cout; using std::endl; using std::string; // etc.
this lets old code compile , doesn't bring std::bind
global namespace.
Comments
Post a Comment