出自 http://www.cplusplus.com/forum/beginner/75706/
To quote the C standard:
An incomplete type may only by used when the size of an object of that type is not needed. It is not needed, for example, when a typedef name is declared to be a specifier for a structure or union, or when a pointer to or a function returning a structure or union is being declared. (See incomplete types in 6.2.5.) The specification has to be complete before such a function is called or defined. |
6.2.5.22 goes on to say:
An array type of unknown size is an incomplete type. It is completed, for an identifier of that type, by specifying the size in a later declaration (with internal or external linkage). |
What does that mean?
It means that for:
| |
For:
| |
For:
| |
Why all this? The background link I posted earlier talks about the history of the treatment of arrays.
编程中,经常需要将一个二维数组作为参数传递给一个函数。当二维数组的行列不确定时,编译会报错。
如果这样定义函数void fun(int matrix[][],int m,int n);则会提示error C2087: '' : missing subscript,因为二维数组作为函数的参数是,二维数组的列值必须确定。