I have the following file aaa.c
:
int Test(const int * const * int_array, int count) {
int min = int_array[0][0];
for (int i = 1; i < count; ++i) {
if (min > int_array[i][0])
min = int_array[i][0];
}
return min;
}
void test_Test(void) {
int i[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int *pi[10] = { &i[0], &i[1], &i[2], &i[3], &i[4], &i[5],
&i[6], &i[7], &i[8], &i[9] };
Test(pi, 10);
}
When I compile it with gcc -c aaa.c
, the following warning is produced:
% gcc -c aaa.c
aaa.c: In function ‘test_Test’:
aaa.c:14:8: warning: passing argument 1 of ‘Test’ from incompatible pointer type
[-Wincompatible-pointer-types]
Test(pi, 10);
^~
aaa.c:1:5: note: expected ‘const int * const*’ but argument is of type ‘int **’
int Test(const int * const * int_array, int count) {
^~~~
Why? What qualifier was discarded? const int * const * int_array
certainly doesn't discard any qualifiers that int **
would have.