F
fkater
Hi,
why doesn't calling f1 (see below) cause a warning while calling f2
does? Both seem to pass the wrong type. Is there another way to
declare f1 so that the caller is forced (warned) if the passed array
hasn't the same elements? I hope this is related to C and not a
question of the used compiler (here: gcc-4.1.2).
void f1(int a[4]){}
void f2(int (*b)[4]){}
int main(int argc,char** argv){
int c[4+1];
int (*d)[4+1];
f1(c); /* no warning */
f2(d); /* warning: incompatible pointer type */
return 0;
}
Felix
why doesn't calling f1 (see below) cause a warning while calling f2
does? Both seem to pass the wrong type. Is there another way to
declare f1 so that the caller is forced (warned) if the passed array
hasn't the same elements? I hope this is related to C and not a
question of the used compiler (here: gcc-4.1.2).
void f1(int a[4]){}
void f2(int (*b)[4]){}
int main(int argc,char** argv){
int c[4+1];
int (*d)[4+1];
f1(c); /* no warning */
f2(d); /* warning: incompatible pointer type */
return 0;
}
Felix