当我使用GCC 4.9.2编译下面的程序时,我得到以下警告:从不兼容的指针类型传递'P'的参数1。但是,我没有看到该计划有任何问题。任何线索?GCC发出不兼容指针类型的警告
typedef int Row[10];
void P(const Row A[])
{
}
int main(void)
{
Row A[10];
P(A);
return 0;
}
下面是完整的输出从GCC标准错误:
test.c: In function ‘main’:
test.c:12:4: warning: passing argument 1 of ‘P’ from incompatible pointer type
P(A);
^
test.c:3:6: note: expected ‘const int (*)[10]’ but argument is of type ‘int (*)[10]’
void P(const Row A[])
^
编辑:程序锵3.5.0选项-pedantic -std=c89 -Wall
完全编译。
你怎么看待'const'预选赛什么? –
@SouravGhosh我认为它承诺调用者参数* A *不会改变。 –
是的,所以,功能期望.......? –