【发布时间】:2019-09-24 20:48:41
【问题描述】:
我创建的 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);
}
但这给了我错误:
>> mpicc -o hprogram hprogram.c
warning: incompatible pointer types passing 'void (void *)' to
parameter of type 'void * _Nullable (* _Nonnull)(void * _Nullable)'
[-Wincompatible-pointer-types]
pthread_create(&threads[i], NULL, function1, (void *)...
^~~~~~~~~~
/usr/include/pthread.h:328:31: note: passing argument to parameter here
void * _Nullable (* _Nonnull)(void * _Nullable),
^
1 warning generated.
这是一个 mpi 程序,我正在使用 pthreads 创建一个混合 mpi。
【问题讨论】: