Webber Webber - 2 months ago 41
C++ Question

Linux C: Reference to non-static member function must be called

error:Reference to non-static member function must be called
Fellow is my codes:

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 try to solve the error, but failed!

Answer

It says you cannot pass pointer to method into pthread_create, you should pass pointer to ordinary function.

Comments