Search code examples
cfunctionprototypewarnings

C Warning : Function was used with no prototype before its definition


I'm facing a warning while compiling a C project:

myFunct was used with no prototype before its definition.

I do not understand this warning since the prototype is indeed before the call of the function.

Here is my code (simplified):

void myFunct();

int main(void)
{
   myFunct();
}

void myFunct()
{
   // Whatever
}

Solution

  • In C, void myFunct(); is a function declaration, that does not include a prototype. It is an obsolescent feature dated back to K&R (pre-standard) C, where function calls and declarations were not checked.

    Replace the declaration with:

    void myFunct(void);