简体   繁体   English

类型'int *'和'long unsigned int'类型的无效操作数到C中的二进制'operator *'错误

[英]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.

相关问题 C错误:类型为'int *'和'unsigned int'的无效操作数为二进制'operator *'| - C error: invalid operands of types 'int*' and 'unsigned int' to binary 'operator*'| 错误,“对二进制 * 的操作数无效(有“long unsigned int”和“int *”)” - Error, 'invalid operands to binary * (have 'long unsigned int' and 'int *')' C 编程错误 二进制 int 和 long long 无符号操作数无效 integer - C Programmıng Error invalid operands to binary int and long long unsigned integer 错误消息:“float”和“int”类型的无效操作数转换为二进制“operator%” - Error Message : Invalid operands of types 'float' and 'int' to binary 'operator%' 二进制错误的无效操作数(有'long unsigned int *'和'int') - Invalid operands to binary errors (have 'long unsigned int *' and 'int') C:无效的二进制操作数>(具有'float'和'float(*)(float **,long int,long int,short int *)') - C: invalid operands to binary > (have ‘float’ and ‘float (*)(float **, long int, long int, short int *)’) 错误:二进制+的无效操作数(有'int *'和'int *')| - error: invalid operands to binary + (have 'int *' and 'int *')| 错误:二进制 * 的无效操作数(有 'int' 和 'int *') - error: invalid operands to binary * (have 'int' and 'int *') 错误:二进制 + 的操作数无效(有 'int *' 和 'int *') - error: invalid operands to binary + (have ‘int *’ and ‘int *’) 二进制 & 的错误操作数无效(有 'int **' 和 'int *') - Error invalid operands to binary & (have 'int **' and 'int *')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM