C 不兼容的指针类型传递';void(void*)到类型为';空虚*

C 不兼容的指针类型传递';void(void*)到类型为';空虚*,c,pthreads,C,Pthreads,我创建了pthread,如下所示: void function1(void *s) { start = (*(int *)s ; } pthread_t threads[numthreads]; int ids[numthreads]; for (i = 0; i < numthreads; i++) { ids[i] = i; int * p = &ids[i] ; pthread_create(&threads[i], NULL, functi

我创建了pthread,如下所示:

void function1(void *s) {
start = (*(int *)s ;
}

pthread_t threads[numthreads];
int ids[numthreads];
for (i = 0; i < numthreads; i++) {
    ids[i] = i;
    int * p = &ids[i] ;
    pthread_create(&threads[i], NULL, function1, (void *)p);
}

这是一个mpi程序,我正在使用pthreads创建一个混合mpi。

pthread\u create()
需要一个指向函数的指针,该函数以
void*
作为输入并返回
void*
作为输出,但您的函数返回的是
void
。您只需在返回类型中添加一个
*
,并添加一个
返回
语句,例如:

void* function1(void *s) {
    start = *(int *)s;
    return NULL; // <-- or whatever you want
}
void*function1(void*s){
开始=*(int*)s;
return NULL;//
pthread_create()
需要一个指向函数的指针,该函数将
void*
作为输入,并将
void*
作为输出,但您的函数将返回一个
void
。您只需在返回类型中添加一个
*
,然后添加一个
return
语句,例如:

void* function1(void *s) {
    start = *(int *)s;
    return NULL; // <-- or whatever you want
}
void*function1(void*s){
开始=*(int*)s;
返回NULL//