-3
呼び出される必要があり、私は次のコードを構築しようとしているerror:Reference to non-static member function must be called
を受け取る:LinuxのC:非静的メンバ関数への参照が
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);
}
}
私は、エラーを解決しようとするいくつかの方法を見つけましたが、失敗しました!
質問をするのを忘れました。どんな問題がありますか? –
あなたはどんなエラーが表示されますか? –
pthreadsはCライブラリですので、C++のメンバ関数ではあまりうまく扱えませんが、単純なラムダを 'pthread_create(&thId、NULL、[this](void * arg){return this->プロセッサ(arg);}、これ); ''これを渡しても、既にラムダ – PeterT