以下代码报错:No matching function call to 'pthread_create'

 1 #include <pthread.h>
 2  
 3 void *draw(void *pt) {
 4     // ...
 5 }
 6  
 7 void *input(void *pt) {
 8     // ....
 9 }
10  
11 void Game::create_threads(void) {
12     pthread_t draw_t, input_t;
13     pthread_create(&draw_t, NULL, &Game::draw, NULL);   // Error
14     pthread_create(&input_t, NULL, &Game::draw, NULL);  // Error
15     // ...
16 }

 

原因:

pthread_create的函数必须为  (void*)(*)(void*) 的格式

 

链接:

http://stackoverflow.com/questions/10389384/no-matching-function-call-to-pthread-create