I receive error:Reference to non-static member function must be called
trying to build the following code:
HTTPClient::HTTPClient(int id,HttpListener& message) {
pthread_t thId;
pthread_create(&thId, NULL, processor, this); <--error is here
}
void* HTTPClient::processor(void* userData) {
HTTPClient* client = static_cast<HTTPClient*>(userData);
client->run();
}
void HTTPClient::run() {
while(true) {
pthread_mutex_lock(&mMutex);
pthread_cond_wait(&mCond,&mMutex);
httpLoadFile(mUrl, mPath);
pthread_mutex_unlock(&mMutex);
}
}
I have found some methods trying to solve the error, but failed!
它说你不能将指向方法的指针传递给pthread_create
,你应该传递指向普通函数的指针。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.