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


You have C code like


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]
main.c:3:5: warning: incompatible implicit declaration of built-in function ‘_exit’



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


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