C++_win32: pthread_self() == pthread_t导致错误
C++_win32: pthread_self() == pthread_t leading to error
我正在尝试将Linux工作应用程序移植到Windows(使用windows.h
和POSIX pthread_win32
)
因此,我定义了一个客户端字段:
struct ClientIdentifier {
pthread_t thread;
int id_client;
...
};
vector<ClientIdentifier> clients;
我正在尝试在客户端字段中查找此客户端的线程(返回字段索引)
int Server::getClientIndex() {
for (unsigned int i = 0; i < clients.size(); ++i) {
if (pthread_self() == clients.at(i).thread) {
return i;
}
}
return -1;
}
但是这个:
pthread_self() == clients.at(i).thread
结果为:
34 D:WORKSPACEC++DSgsserver.cpp no match for 'operator==' in 'pthread_self() == (((std::vector<ClientIdentifier, std::allocator<ClientIdentifier> >*)((Server*)this)) + 8u)->std::vector<_Tp, _Alloc>::at [with _Tp = ClientIdentifier, _Alloc = std::allocator<ClientIdentifier>](i)->ClientIdentifier::thread'
note C:programyDevCppincludeobjbase.h:80 candidates are: BOOL operator==(const GUID&, const GUID&)
我该如何解决这个问题?
使用 pthread_equal()
比较pthread_t
值。
相关文章:
- Pthread段错误,使用指向main中变量的指针
- C++ PTHREAD 错误:非静态成员函数的使用无效
- Opencv分段错误使用pthread捕获帧C++
- C++/pthread/join 错误消息的含义 "what(): Invalid argument"
- 加入pthread时出现分段错误
- Pthread模板参数错误
- pthread分配输出错误
- 运行我的 C++ Pthread 程序时出错 - 分段错误(核心转储)
- pthread 在分离的线程上创建错误 11
- 当g++静态链接pthread时,导致Segmentation错误,原因何在
- 这是pthread C++程序的不可移植错误吗
- 为什么在 C++ 中将函数作为参数传递给 pthread 时会出现"non-static member function"错误?
- 错误:' pthread '没有命名类型
- "多个定义"错误指向pthread.h
- pthread在c++中创建错误
- 错误: C1083: 无法打开包含文件:"pthread.h": 没有此类文件或目录
- 使用 pthread 的多个参数(带结构)错误
- pthread程序导致Linux机器出现分段错误.在Cygwin64上工作良好
- 在c++中使用pthread时的编译错误
- Pthread查询:线程顺序错误