clang "error: call to undeclared function; ISO C99 ... implicit declarations" in CI
Recent clang makes calling a function with no visible declaration an error in C, not a warning. The fix is to include the header that declares it rather than letting C assume an int-returning prototype.
What this error means
C code that built on older toolchains fails on newer clang with "call to undeclared function", pointing at a call whose header was never included.
clang
main.c:5:9: error: call to undeclared function 'strdup'; ISO C99 and later
do not support implicit function declarations [-Wimplicit-function-declaration]
5 | char *p = strdup(s);
| ^Common causes
How to fix it
Include the declaring header
- Find which header declares the function and include it.
- Recompile so the prototype is visible at the call site.
C
#include <string.h> /* declares strdup */Define the required feature macro
Some POSIX or GNU functions need a feature-test macro before any include so their prototypes are exposed.
C
#define _GNU_SOURCE
#include <string.h>How to prevent it
- Include the correct headers and define needed feature-test macros so prototypes are visible; do not rely on implicit declarations that newer C compilers reject.
Related guides
clang "error: no member named X in namespace std" in CIFix clang "error: no member named X in namespace std" in CI - the standard header that declares std::X is not…
gcc "warning: multi-character character constant" treated as error in CIFix gcc "warning: multi-character character constant [-Wmultichar]" promoted to an error in CI - single quote…