有人可以告诉我我做错了什么? (我省略了计划,因为它很长的休息...)无法正确创建线程
#include <pthread.h>
void *RTPfun(char *client_addr);
int main(int argc, char *argv[])
{
char* client_addr;
pthread_t RTPthread;
// ...
pthread_create(&RTPthread, NULL, &RTPfun, client_addr)
}
void *RTPfun(char * client_addr)
{
// ...
return;
}
错误:
TCPserver.c: In function ‘main’: TCPserver.c:74:5: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [enabled by default] /usr/include/pthread.h:225:12: note: expected ‘void * (*)(void *)’ but argument is of type ‘void * (*)(char *)’
你的编译器还应该警告你如果在函数中使用'return;'而没有使用非''void'返回类型的函数表达式。如果该返回语句实际上已经达到,那么您的程序具有未定义的行为。 – Casey