我正在写一个连接到CAN接口的C++程序(用于arm架构)。 我正在使用标准套接字,绑定,recv和send函数。 现在我处于需要将一些函数外包给线程的地步。 为此,我想使用C++ 0x线程,因为我在这里读到pthreads不应该用于C++应有的兼容性问题。所以我包括线程库#include <thread>
。并添加到我的编译器调用的选项-Wno-psabi -std=c++0x -lpthread
C++ 0x线程和套接字
(-Wno-psabi
是否有禁用note: the mangling of ‘va_list’ has changed in GCC 4.4
消息)
错误我得到的是:
25: error: no match for ‘operator<’ in ‘std::bind(_Functor, _ArgTypes ...) [with _Functor = int, _ArgTypes = sockaddr*, unsigned int](((sockaddr*)(&((can*)this)->can::addr)), 16u) < 0
/usr/arm-linux-gnueabi/include/c++/4.4.5/system_error:258: note: candidates are: bool std::operator<(const std::error_condition&, const std::error_condition&)
/usr/arm-linux-gnueabi/include/c++/4.4.5/system_error:177: note: bool std::operator<(const std::error_code&, const std::error_code&)
我认为来自线程库的绑定函数正在重写来自套接字的绑定函数。
如何告诉编译器什么时候使用什么函数?
IM使用arm-linux-gnueabi-g++
版本4.4.5
尝试使用':: bind'的C函数,或者不使用'使用命名空间std'并完全限定你的'std'函数调用。 – didierc
::绑定作品。 但我即将限定我的'std'函数调用。谢谢! 如果你可以发布这个答案,我会将它标记为正确的答案。 – baam