Coding⏱️ 2 min read📅 2026-06-03

How to Fix: Warning/error "function declaration isn't a prototype"

Error: function declaration isn't a prototype. Solution: Provide implementation for function or use extern keyword correctly.

Quick Answer: Move function declaration to source file or provide definition in header file.

The warning/error 'function declaration isn't a prototype' occurs when you are trying to declare a function as both a function and an external variable in the same scope. In your case, the problem lies in the definition of `testlib()` in `mylib.c` where it's declared as `extern int testlib();`. This indicates that `testlib()` is only defined elsewhere (i.e., not in the current file), but you are trying to use its address by calling `testlib()`. To fix this, remove the `extern` keyword from the declaration of `testlib()` and define it as a regular function. Here's how your corrected code shouldlook like:

🔧 Proven Troubleshooting Steps

Method 1: Correct Declaration

  1. Step 1: Remove the `extern` keyword from the declaration of `testlib()` in `mylib.h`. The corrected code should look like this:

Method 2: Correct Implementation

  1. Step 1: Define `testlib()` as a regular function in `mylib.c`. The corrected code should look like this:

💡 Conclusion

By following these steps, you will be able to successfully compile and run your program.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions