Reputation: 433
C newbie here. Trying to figure out the error in my program.
Function prototype:
float* convolve(int (*)[10], int (*)[3], int *, int);
actual function:
float* convolve(int* ImdataPtr, int* KernelPtr, int* size, int sizeKernel)
How it's called in main:
float* output;
output = convolve(input,kernel,sizeIm,3);
Compile Error:
program.c:55:8: error: conflicting types for ‘convolve’
Help, please...
Upvotes: 0
Views: 164
Reputation: 9503
Your prototype specifies, for its first and second arguments, pointer to an array of integers , whereas in your function, you are specifying integer pointers alone.
You need to either correct your prototype, or your function definition.
Upvotes: 1
Reputation: 54242
The problem is that the prototype doesn't match. Make sure the types are exactly the same, since int(*)[10]
and int(*)[3]
are different types than int*
:
float* convolve(int(*)[10], int(*)[3], int*, int);
float* convolve(int (*ImdataPtr)[10], int (*KernelPtr)[3], int* size, int sizeKernel) {
// etc
}
You can (and probably should) even make them exactly the same, including argument names:
float* convolve(int (*ImdataPtr)[10], int (*KernelPtr)[3], int* size, int sizeKernel);
float* convolve(int (*ImdataPtr)[10], int (*KernelPtr)[3], int* size, int sizeKernel) {
// etc
}
I had to look up how to declare these, so you might find the question on C pointer to array/array of pointers disambiguation useful too. int*[3]
is an array of pointers to int
(just read it backwards), but int(*)[3]
is a pointer to an array of int
.
Upvotes: 6