D
dev
I hav read it in previous posts that we should declare function before
it is called.
but one question regarding implicit declaration ,that i found
accidently..
int main()
{
maw(32,3,95,38,20,15);
return 0;
}
void maw(int a,int b,...)
{
/*.....................*/
}
vikas@vikas-laptop:~$ gcc -W -O0 deu.c
deu.c:12: warning: conflicting types for ‘maw’
deu.c:7: warning: previous implicit declaration of ‘maw’ was here
I get warnings compiling this code....
but when i changed the return type of functions from void to int and
compile,ie,
int maw(int a,int b,...)
{
/*.....................*/
}
vikas@vikas-laptop:~$ gcc -W -O0 deu.c
deu.c:12: error: conflicting types for ‘maw’
deu.c:13: note: a parameter list with an ellipsis can’t match an empty
parameter name list declaration
deu.c:7: error: previous implicit declaration of ‘maw’ was here
I get errors.I cant understand Why there is only a warning in first
case and in second case it is leading to error.
please help me understand the fact behind it..
-
regards
it is called.
but one question regarding implicit declaration ,that i found
accidently..
int main()
{
maw(32,3,95,38,20,15);
return 0;
}
void maw(int a,int b,...)
{
/*.....................*/
}
vikas@vikas-laptop:~$ gcc -W -O0 deu.c
deu.c:12: warning: conflicting types for ‘maw’
deu.c:7: warning: previous implicit declaration of ‘maw’ was here
I get warnings compiling this code....
but when i changed the return type of functions from void to int and
compile,ie,
int maw(int a,int b,...)
{
/*.....................*/
}
vikas@vikas-laptop:~$ gcc -W -O0 deu.c
deu.c:12: error: conflicting types for ‘maw’
deu.c:13: note: a parameter list with an ellipsis can’t match an empty
parameter name list declaration
deu.c:7: error: previous implicit declaration of ‘maw’ was here
I get errors.I cant understand Why there is only a warning in first
case and in second case it is leading to error.
please help me understand the fact behind it..
-
regards