warning: conflicting types for function

always make sure your function prototype declaration and function declaration should match with the same number of arguments with the same type and the same return type of function

warning: conflicting types for function means the compiler found the function declaration with return type as void  and couldn’t find the function prototype declaration of that function

thereupon, the compiler will create an implicit function prototype declaration for you and assume the return type of that function to be an int

conflicting types means the compiler created  an implicit function prototype declaration with return type int but you have used void as a return type in your function declaration

let’s see an example to clarify

#include <stdio.h>
//void myFunction();//function prototype declaration


int main() {
  myFunction(); // function call
  return 0;
}
// Create a function called myFunction
 void myFunction()//function declaration
 {
  printf("I just got executed!");
}

in the above example, you can see the compiler couldn’t find the function prototype declaration and because of that it will create an implicit function prototype declaration with return type int

as a result, a conflict of types warning is created

but why?

because the implicit function prototype declaration return type  is int and it is not matched with the function declaration return type which is void

Mohammed Anees

Hey there, welcome to aneescraftsmanship I am Mohammed Anees an independent developer/blogger. I like to share and discuss the craft with others plus the things which I have learned because I believe that through discussion and sharing a new world opens up

Leave a Reply

Your email address will not be published.