Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Linux C:必须调用对非静态成员函数的引用_C++_Linux - Fatal编程技术网

C++ Linux C:必须调用对非静态成员函数的引用

C++ Linux C:必须调用对非静态成员函数的引用,c++,linux,C++,Linux,我收到错误:必须调用对非静态成员函数的引用以尝试生成以下代码: HTTPClient::HTTPClient(int id,HttpListener& message) { pthread_t thId; pthread_create(&thId, NULL, processor, this); <--error is here } void* HTTPClient::processor(void* userData) { HTTPClient*

我收到
错误:必须调用对非静态成员函数的引用
以尝试生成以下代码:

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);
    }
}
HTTPClient::HTTPClient(int-id、HttpListener和message){
pthread_t thId;
pthread_create(&thId,NULL,processor,this);run();
}
void HTTPClient::run(){
while(true){
pthread_mutex_lock(&mMutex);
pthread_cond_wait(&mCond,&mMutex);
httpLoadFile(mUrl,mPath);
pthread_mutex_unlock(&mMutex);
}
}

我找到了一些解决错误的方法,但是失败了

它说您不能将指向方法的指针传递到
pthread\u create
,您应该传递指向普通函数的指针。

您忘记问问题了。你到底看到了什么问题?你看到的是什么错误?pTrac是C++库,所以它对C++成员函数处理得不太好,但是你可以用一个简单的lambda作为一个解决方案<代码> pthRead创建((th.th.d[/],null),[{ this ](空隙*ARG){返回->处理器(ARG);},这个);代码>虽然传递
这个
看起来有点傻,如果它已经在lambda中被捕获了