我正在尝试使用以下代码在 C++ 中创建一个线程:
pthread_t mythread;
void* f (void*) = MyClass::myfunction;
pthread_create(&mythread, NULL, &f, NULL);
它不工作。知道有什么问题吗?
myfunction 的类型为:
void* MyClass::myfunction(void* argv);
返回的错误是:
error: declaration of ‘void* Class::f(void*)’ has ‘extern’ and is initialized
error: invalid pure specifier (only ‘= 0’ is allowed) before ‘::’ token
error: function ‘void* Class::f(void*)’ is initialized like a variable