Reputation: 41
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. I am fairly new to C so its probably a simple fix
Upvotes: 0
Views: 4467
Reputation: 212969
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
.
Upvotes: 6