[英]invalid operands of types ‘int*’ and ‘long unsigned int’ to binary ‘operator*’ error in C
So I keep getting the following compilation error; 因此,我不断收到以下编译错误;
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*)’
This error relates to the following part of the code 此错误与代码的以下部分有关
int wkspSize = 32*(npart+NGRID)+1000;
float* WKSP = (float*) malloc(wkspSize*sizeof(float));
int hfmmInfoSize = 4;
int* hfmmInfo = (int*) malloc(&hfmmInfoSize*sizeof(int));
I am struggling to find where this error is exactly. 我正在努力找到此错误的确切位置。 I have tried changing the both the 27th argument (hffmInfoSize) so that it is given as float and I have tried changing the final line as a float.
我尝试更改两个第27个参数(hffmInfoSize),以便将其指定为float,并且尝试将最后一行更改为float。 I am fairly new to C so its probably a simple fix
我对C相当陌生,因此可能很简单
You have a stray &
in there it seems - change: 你有一个流浪
&
在那里似乎-变化:
int* hfmmInfo = (int*) malloc(&hfmmInfoSize*sizeof(int));
to: 至:
int* hfmmInfo = malloc(hfmmInfoSize*sizeof(int));
Note also the removal of the redundant (and potentially dangerous) cast on the result of the call to malloc
. 另请注意,删除了对
malloc
的调用结果所产生的冗余(且可能有危险) 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.