C: warning: implicit declaration of function 'foo' [-Wimplicit-function-declaration]
In C you called a function the compiler has not seen declared — usually a missing #include. Newer compilers treat it as an error.
implicit declaration of functioncall to undeclared functionerror: implicit declaration of functionconflicting types for built-in function Meaning
Old C assumed an undeclared function returns int and accepts anything. That hides bugs such as truncated pointers on 64-bit systems. GCC 14 and Clang 16 turn it into a hard error, so old code that merely warned before may now fail to build.
Common causes
- Missing
#include <stdlib.h>,<string.h>,<unistd.h>or similar - Calling a function defined later in the file without a prototype
- Misspelled function name
- Header not found because of a missing feature-test macro such as
_GNU_SOURCE
⚡ Quick fix
- Include the header that declares it (see
man 3 name) - Add a prototype above the first use
- Compile with
-Wall -Werror=implicit-function-declaration
Detailed fix by platform
GCC / Clang
man 3 strdupshows the header and feature macros- Add
#define _GNU_SOURCEor_POSIX_C_SOURCE 200809Lbefore the includes if the man page says so
Code examples
Declaring before use
#include <stdlib.h> /* declares malloc, free, atoi */
#include <string.h> /* declares strlen, memcpy */
int main(int argc, char** argv) {
int n = argc > 1 ? atoi(argv[1]) : 0; /* without stdlib.h: implicit declaration of function 'atoi' */
return n;
}How to diagnose
- Name — Spelling of the function?
- Header — Which header does man say?
- Standard — Is the file compiled as C99 or newer?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- C4996 MSVC: error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead
- comparison of integers of different signs C/C++: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' [-Wsign-compare]
- control reaches end of non-void function C/C++: warning: control reaches end of non-void function [-Wreturn-type]
Most viewed in C/C++
- terminate called after throwing an instance of C++: terminate called after throwing an instance of 'std::out_of_range' — what(): vector::_M_range_check
- double free or corruption C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped)
- expected ';' before C/C++: error: expected ';' before 'x' — missing semicolon
Other ways to find it
Where this error sits
Origin: Application & API. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 15 Oct 2026