所以我不断收到以下编译错误;
src/c/testHO.c: In function ‘int main(int, char**)’:
src/c/testHO.c:79:56: error: invalid operands of types ‘int*’ and ‘long unsigned int’ to binary ‘operator*’
src/c/testHO.c:145:26: error: cannot convert ‘int*’ to ‘float*’ for argument ‘27’ to ‘void hfmmcalc_(float*, float*, float*, float*, int*, int*, float*, float*, int*, double*, int*, int*, float*, float*, float*, float*, int*, int*, float*, float*, int*, int*, float*, int*, int*, float*, float*, float*, int*, int*)’
此错误与代码的以下部分有关
int wkspSize = 32*(npart+NGRID)+1000;
float* WKSP = (float*) malloc(wkspSize*sizeof(float));
int hfmmInfoSize = 4;
int* hfmmInfo = (int*) malloc(&hfmmInfoSize*sizeof(int));
我正在努力找到这个错误的确切位置。我已经尝试更改第27个参数(hffmInfoSize),以便它以float形式给出,我尝试将最后一行更改为float。我对C很新,所以它可能是一个简单的修复
答案 0 :(得分:6)
你似乎有一个迷路&
- 改变:
int* hfmmInfo = (int*) malloc(&hfmmInfoSize*sizeof(int));
为:
int* hfmmInfo = malloc(hfmmInfoSize*sizeof(int));
另请注意删除malloc
调用结果的redundant (and potentially dangerous) cast。