my code is
void doc(){
//mycode
return;
}
my warning is
conflicting types for 'doc'
can anybody solve it.
my code is
void doc(){
//mycode
return;
}
my warning is
conflicting types for 'doc'
can anybody solve it.
That's clearly not your complete code.
However, that error means that there is another declaration for doc
(perhaps a global variable? something in a header file?) that isn't a void
function that takes no parameters.
u have declared it with some other type/signature and defined with some other type/signature..
like
int doc();
void doc()
{
}
will give u this warning.
"doc" is probably already declared with a different type... you should try to find the previous declaration !
In C, if you don't have a prototype for a function when you call it, it is assumed to return an int
and to take an unspecified number of parameters. Then, when you later define your function as returning void
and taking no parameters, the compiler sees this as a conflict.
Depending upon the complexity of your code, you can do something as simple as moving the definition of the function before its use, or add the function declaration in a header file and include it.
In any case, the net effect should be to make the function prototype available before it is being used.
If you add
void doc(void);
before the function use, you will have a prototype visible in scope, and your warning will go away.
I think this is the most likely cause for your warning. You could have an explicit incompatible declaration of doc
in your code, but we can't tell because you have not posted complete code.
You have either declared doc
before, or made a call to undeclared doc
thus forcing the compiler to deduce a probable parameter declaration for doc
from that call. Now, the definition of doc
that you quoted is different from that previous declaration (either explicit or deduced by the compiler), which is what is reported as a "conflict".
Make sure that you have not used doc any where in your code !, I think that only gives u trouble!
try writing your doc function before your main function in your program file.