我正在尝试使用该pthread库来计算可以来自 range的n斐波那契数。当我尝试将我的类型转换为.n0-1000void*double
在我的主要内容中,我调用了我的计算斐波那契函数:
pthread_create(&tid, &attr, calc_fib, (void *)n);
在我的calc_fib函数中,我尝试使用以下方式进行类型转换:
void *calc_fib( void *num)
{
double n;
n = (double)num;
...
但是,当我尝试这样做时,会出现以下错误:
In function ‘calc_fib’:
error: pointer value used where a floating point value was expected
In function ‘main’:
error: cannot convert to a pointer type
我无法在 C 中从void*to进行类型转换,double还是我做错了?