How to fix C warning ‘implicit declaration of function _exit’

Problem:

You have C code like

_exit(1);

but when you try to compile it you see a warning message like

main.c: In function ‘main’:
main.c:3:5: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
     _exit(1);
     ^~~~~
main.c:3:5: warning: incompatible implicit declaration of built-in function ‘_exit’

Solution:

Add

#include <unistd.h>

at the top of the source file where the error occured.

Note that in case you use _Exit(...) (capital E) instead of _exit(...), you need to add

#include <stdlib.h>

instead.

Read the manpage for _exit in case you need further information on _exit(...).