當我使用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 *不會改變。 –
是的,所以,功能期望.......? –