以下代码报错:No matching function call to 'pthread_create'
#include <pthread.h>
void *draw(void *pt) {
// ...
}
void *input(void *pt) {
// ....
}
void Game::create_threads(void) {
pthread_t draw_t, input_t;
pthread_create(&draw_t, NULL, &Game::draw, NULL); // Error
pthread_create(&input_t, NULL, &Game::draw, NULL); // Error
// ...
}
原因:
pthread_create的函数必须为 (void*)(*)(void*) 的格式
ref:http://stackoverflow.com/questions/10389384/no-matching-function-call-to-pthread-create