implicit declaration of function C/C++ Origin: Application & API Last updated 15 Oct 2026

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.

Exact message you may see implicit declaration of functioncall to undeclared functionerror: implicit declaration of functionconflicting types for built-in function
Seen on: C/C++ GCC Clang

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

  1. Include the header that declares it (see man 3 name)
  2. Add a prototype above the first use
  3. Compile with -Wall -Werror=implicit-function-declaration

Detailed fix by platform

GCC / Clang

  1. man 3 strdup shows the header and feature macros
  2. Add #define _GNU_SOURCE or _POSIX_C_SOURCE 200809L before the includes if the man page says so

Code examples

Declaring before use

c
#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

  1. Name — Spelling of the function?
  2. Header — Which header does man say?
  3. 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:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

C4996 — MSVC: error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead (C/C++)C4996comparison of integers of different signs — C/C++: warning: comparison of integer expressions of different signedness: 'int' and 'size_t' [-Wsign-compare] (C/C++)comparison of integer…control reaches end of non-void function — C/C++: warning: control reaches end of non-void function [-Wreturn-type] (C/C++)control reaches end o…format expects argument of type — C: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long int' [-Wformat=] (C/C++)format expects argume…incomplete type — C++: error: invalid use of incomplete type 'class X' — forward declaration only (C/C++)incomplete typemultiple definition of — C/C++: multiple definition of `x'; first defined here — ld returned 1 exit status (C/C++)multiple definition ofredefinition of — C++: error: redefinition of 'class X' / multiple definition — missing include guard (C/C++)redefinition ofSegmentation fault — C/C++: Segmentation fault (core dumped) — SIGSEGV from a null, dangling or out-of-bounds pointer (C/C++)Segmentation faultimplicit …

Explore the map of this error Full error map →

🧠 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.