问个g++的问题# Programming - 葵花宝典
l*i
1 楼
如下一段code:
int PrecFunc(void *params)
{
double m1 = *(double *)params;
double m2 = *(double *)(params+sizeof(double));
double M = *(double *)(params + sizeof(double)*2);
double mu = *(double *)(params + sizeof(double)*3);
double eta = *(double *)(params + sizeof(double)*4);
double m = *(double *)(params + sizeof(double)*5);
... ...
}
如果存成.c文件用gcc编译可以通过,但是存成.cpp文件用g++编译就会说
"error: pointer of type ‘void *’ used in arithmetic"
因为用到现有的一个函数库,PrecFunc的输入参数类型必须是void *,应该
怎么样修改才能在gcc和g++下编译都通过呢?
int PrecFunc(void *params)
{
double m1 = *(double *)params;
double m2 = *(double *)(params+sizeof(double));
double M = *(double *)(params + sizeof(double)*2);
double mu = *(double *)(params + sizeof(double)*3);
double eta = *(double *)(params + sizeof(double)*4);
double m = *(double *)(params + sizeof(double)*5);
... ...
}
如果存成.c文件用gcc编译可以通过,但是存成.cpp文件用g++编译就会说
"error: pointer of type ‘void *’ used in arithmetic"
因为用到现有的一个函数库,PrecFunc的输入参数类型必须是void *,应该
怎么样修改才能在gcc和g++下编译都通过呢?