Solve Error: Implicit Declaration of Function in C

We are very much familiar with the flow control in C where it follows the Top-Down approach, and when we are writing a C program and if we are using any function, we might come across a very common error ‘Implicit declaration of function’.

Now why this error occurred? The answer is already in the error.

We have used a function in our program which is not declared yet or we can say that we have used a function implicitly.

Implicit declaration of the function is not allowed in C programming. Every function must be explicitly declared before it can be called.

In C90, if a function is called without an explicit declaration, the compiler is going to complain about the implicit declaration.

Here is a small code that will give us an Implicit declaration of function error.

Now the above code will give you an error of Implicit declaration.

Here are some of the reasons why this is giving error.

  1. Using a function that is pre-defined but you forget to include the header file for that function.
  2. If you are using a function that you have created but you failed to declare it in the code. It’s better to declare the function before the main.

In C90, this error can be removed just by declaring your function before the main function.

For example:

In the case of C99, you can skip the declaration but it will give us a small warning and it can be ignored but the definition of the function is important.

This gives us the output:

Here you can see that our code is working fine and a warning is generated but we are good to go but this is not recommended.

Well, this was all about the Implicit declaration of the function in C and the error related to it. If you are stuck into any kind of error, don’t forget to google it and try to debug it on your own. This will teach you how to debug on your own as someone might have faced a similar problem earlier.

If you still don’t find any solution for your problem, you can ask your doubt in the comment’s section below and we’ll get back to you🤓.

Thanks for your visit and if you are new here, consider subscribing to our newsletter. See you in my next post. Bye!

1 thought on “Solve Error: Implicit Declaration of Function in C”

  1. how can i remove implicit declaration of mkfifo function error:
    #include
    mkfifo(“pipeA”,0666);
    mkfifo(“pipeB”,0666);
    void main()
    {
    int f1,f2;
    f1 = mkfifo(“pipeA”,0666);
    if(f1<0)
    printf("\npipeA was not created");
    else
    printf("\npipeA created");
    f2 = mkfifo("pipeB",0666);
    if(f2<0)
    printf("\npipeB was not created");
    else
    printf("\npipeB is created\n");
    }

Leave a Comment

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