小编fsi*_*idi的帖子

如何修复此Pthread示例中的错误?

我做了所有必要的配置,比如包括Pthread库和头文件......

错误是:

error C3867: 'FunctionClass::calledfunction': function call missing argument list; use '&FunctionClass::calledfunction' to create a pointer to member
Run Code Online (Sandbox Code Playgroud)

这是导致错误的示例:

class FunctionClass
{

 public:

    void * calledfunction( void *);
    /*
    this is the definition of the function in the FunctionClass.cpp
    void * FunctionClass::calledfunction( void *)
    {
        //do sth;
    }

    */


};

int main(void)
{

pthread_t process_m;
FunctionClass *obj = new FunctionClass ();

int nbr= 5;

if(pthread_create(&process_m,NULL,obj->calledfunction,(void *)nbr)< 0)
    {
        std::cout << "thread1";

}
 }
Run Code Online (Sandbox Code Playgroud)

什么可能导致错误?我尊重函数pthread_create的语法......但是我找不到这个错误的原因!

c++ pthreads

0
推荐指数
1
解决办法
1052
查看次数

标签 统计

c++ ×1

pthreads ×1