参考までですが(10がかぶっているので5と10にしています)
void func(const int a[5][10]) は、仮引数として2次元配列 a を
宣言していますが、定義されるのは(型調整により)
要素数10の配列全体のアドレスを格納可能なポインタ変数です。
(定義結果は const int (*a)[10] です)
6.7.5.3から抜粋します。
7 Adeclaration of a parameter as "array of <i>type</i>" shall be adjusted to "qualified pointer to <i>type</i>", where the type qualifiers (if any) are those specified within the [and] of the array type derivation. If the keyword <b>static</b> also appears within the [and] of the array type derivation, then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as manyelements as specified by the size expression.
それはそれとして、実引数の int [10][10]と仮引数の const int [10][10]って、compatibleなの?
つまり、gccが間違ったwarinigを出してるのか、黙って通すVisualStudio.Netコンパイラの方が間違っているのか。I
ISOの規格書を斜め読みしただけでは分かりませんでした。時間が出来たらじっくり読んでみるけど。
main.c:1:22: Function parameter a declared as manifest array (size constant is
meaningless)
A formal parameter is declared as an array with size. The size of the array
is ignored in this context, since the array formal parameter is treated as a
pointer. (Use -fixedformalarray to inhibit warning)
main.c: (in function main)
main.c:9:8: Passed storage a not completely defined (*a is undefined): func (a)
Storage derivable from a parameter, return value or global is not defined.
Use /*@out@*/ to denote passed or returned storage which need not be defined.
(Use -compdef to inhibit warning)
$ lint -strict main.c
Splint 3.1.1 --- 02 May 2003
main.c:1:22: Function parameter a declared as manifest array (size constant is
meaningless)
A formal parameter is declared as an array with size. The size of the array
is ignored in this context, since the array formal parameter is treated as a
pointer. (Use -fixedformalarray to inhibit warning)
main.c: (in function func)
main.c:1:22: Parameter a not used
A function parameter is not used in the body of the function. If the argument
is needed for type compatibility or future plans, use /*@unused@*/ in the
argument declaration. (Use -paramuse to inhibit warning)
main.c:5:5: Function main declared without parameter list
A function declaration does not have a parameter list. (Use -noparams to
inhibit warning)
main.c: (in function main)
main.c:9:8: Passed storage a not completely defined (*a is undefined): func (a)
Storage derivable from a parameter, return value or global is not defined.
Use /*@out@*/ to denote passed or returned storage which need not be defined.
(Use -compdef to inhibit warning)
main.c:9:2: Undetected modification possible from call to unconstrained
function func: func
An unconstrained function is called in a function body where modifications
are checked. Since the unconstrained function may modify anything, there may
be undetected modifications in the checked function. (Use -modunconnomods to
inhibit warning)
main.c:9:2: Statement has no effect (possible undected modification through
call to unconstrained function func): func(a)
Statement has no visible effect --- no values are modified. It may modify
something through a call to an unconstrained function. (Use -noeffectuncon to
inhibit warning)
main.c:1:6: Function exported but not used outside main: func
A declaration is exported, but not used outside this module. Declaration can
use static qualifier. (Use -exportlocal to inhibit warning)
main.c:3:2: Definition of func
main.c:1:6: Function func exported but not declared in header file
A declaration is exported, but does not appear in a header file. (Use
-exportheader to inhibit warning)
main.c:3:2: Definition of func