Skip to content
Latchkey

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

  1. Find which header declares the function and include it.
  2. 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →