Question

I have the following arrays:

char* mask[9];
int hSobelMask[9] = {
    -1, -2, -1,
    0, 0, 0,
    1, 2, 1};

I want to give a pointer on this array to a method like this:

int H = applyMask(&mask, &hSobelMask);

The signature of the applyMask function is the folowing:

int applyMask(char** mask[9], int* sobelMask[9]);

But I get the following compile warning:

demo.c: In function ‘customSobel’:
demo.c:232:7: warning: passing argument 1 of ‘applyMask’ from incompatible pointer type
demo.c:181:5: note: expected ‘char ***’ but argument is of type ‘char * (*)[9]’
demo.c:232:7: warning: passing argument 2 of ‘applyMask’ from incompatible pointer type
demo.c:181:5: note: expected ‘int **’ but argument is of type ‘int (*)[9]’

What does this warning mean, how do I get rid of it ?

Was it helpful?

Solution

You want to pass the pointers to these arrays? So you're probably looking for this:

int applyMask(char* (*mask)[9], int (*sobelMask)[9]);

OTHER TIPS

int applyMask(char** mask, int* sobelMask);

A char * ___[9] is an array of char *, and a char * * ___[9] is an array of char * *. They're not compatible. Just change your function signature to this:

int applyMask(char** mask, int* sobelMask)

or this:

int applyMask(char* mask[], int sobelMask[])

Edited to add (after Shahbaz's comment below): Call your function like this:

int H = applyMask(mask, hSobelMask);

There's no need for those &s, since an array variable already is a pointer to the contents of the array.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top