我有以下文件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);
}
Run Code Online (Sandbox Code Playgroud)
当我编译它时gcc -c aaa.c,会产生以下警告:
% 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) {
^~~~
Run Code Online (Sandbox Code Playgroud)
为什么?什么资格赛被丢弃了?const int * const * int_array当然不会丢弃任何可能的限定词int **.
| 归档时间: |
|
| 查看次数: |
321 次 |
| 最近记录: |