我有功能,我在其中创建新功能,pthread
然后再使用它
void Client::initialize(Client * c) {
//some unimportant code here
pthread_t thread;
pthread_create(&thread, NULL,
c->sendMessage, (void *) fd);
//some unimportant code here
}
Client::Client() {
initialize(this);
}
sendMessage
功能:
void * Client::sendMessage(void *threadid) {
//unimportant code here
this->showHelp();
//unimportant code here
return NULL;
}
的声明showHelp
void Client::showHelp() {
//some code
}
当我尝试编译它时,我得到了这个错误:
g++ -Wall -pedantic -Wno-long-long -O0 -ggdb -pthread -lncurses -g -c ./Client.cpp
./Client.cpp: In static member function ‘static void* Client::sendMessage(void*)’:
./Client.cpp:244:13: error: ‘this’ is unavailable for static member functions
make: *** [Client.o] Error 1
这怎么可能,什么时候sendMessage
没有声明为static
?有什么办法吗?