我正在尝试将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:\WORKSPACE\C++\DS\gs\server.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:\programy\DevCpp\include\objbase.h:80 candidates are: BOOL operator==(const GUID&, const GUID&)
我该如何解决?