Solved – Implicit declaration of function in C Language

By | May 5, 2018

implicit declaration of function

The implicit declaration of function error is very common in C language. Either you are a beginner in C or moved to C from a high-level language. C is procedural programming language. So it is very important to declare every function before using. The flow control works on Top-Down basis.


int main()
    callit(1, "12"); /* Declare that function before using it */       
    return 0;

int callit(int x, char *p)
    /* Some Code */

The actual error message is

warning: implicit declaration of function

What causing Implicit declaration of function error in C?

This error will generally show the name of the function in the compiler. You are using the function without declaring it.


Solution of Implicit declaration of function

1) If you are using pre-defined function then it is very likely that you haven’t included the header file related to that function. Include the header file in which that function is defined.

#include <unistd.h>

2) If you are using any custom function then it is a good practice to declare the function before main. Sometimes the problem comes due to the return type of the function. By default, C language assumes the return type of any function as ‘int’. So, declare the function before main, that will definitely resolve that issue.

int callit(int x, char *p); /* Declare it in this way before main */


Final Words

If you are still getting any problem, then feel free to comment down your code.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.