# Fix the C 'implicitly declaring library function' warning

> Learn how to fix the C 'implicitly declaring library function' warning, shown when you call functions like printf or strlen without including their header.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2020-02-17 | Topics: [C](https://flaviocopes.com/tags/clang/) | Canonical: https://flaviocopes.com/c-error-implicit-declare-library-function/

When compiling a [C](https://flaviocopes.com/c-introduction/) program you might find that the compiler gives you a warning similar to

```
hello.c:6:3: warning: implicitly declaring library function
      'printf' with type 'int (const char *, ...)'
      [-Wimplicit-function-declaration]
  printf("Name length: %u", length);
  ^
```

or

```
hello.c:5:16: warning: implicitly declaring library function
      'strlen' with type 'unsigned long (const char *)'
      [-Wimplicit-function-declaration]
  int length = strlen(name);
               ^
```

This problem occurs because you used a function from the standard library without first including the appropriate header file.

The compiler will also give you a suggestion, like the following one:

```
hello.c:5:16: note: include the header <string.h> or
      explicitly provide a declaration for 'strlen'
```

which points you in the right direction.

In this case, adding

```c
#include <stdio.h>
```

at the top of the C file will solve the issue.
