I’m trying to port linux working application to windows (using windows.h and POSIX pthread_win32)
So, I have a field of clients defined:
struct ClientIdentifier {
pthread_t thread;
int id_client;
...
};
vector<ClientIdentifier> clients;
and I’m trying to find thread of this client in field of clients (returning index of field)
int Server::getClientIndex() {
for (unsigned int i = 0; i < clients.size(); ++i) {
if (pthread_self() == clients.at(i).thread) {
return i;
}
}
return -1;
}
But this:
pthread_self() == clients.at(i).thread
results to:
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&)
How can I solve that?
Use
pthread_equal()to comparepthread_tvalues.