I have an application that has normally compiled fine. It uses two “non-standard” functions (both in cstdlib if I’m not mistaken): sleep() and daemon(). Upon updating my system I discovered my program will no longer compile (it still compiles on an older system of mine). GCC gives me this message:
error: 'daemon' was not declared in this scope
error: 'sleep' was not declared in this scope
I remember once in the past I had this same issue with sleep() and including cstdlib resolved the problem. I cannot find a change log for cstdlib and have no idea where the function was moved to (if not removed). I am also assuming the same thing happened to daemon(). I cannot find anything related to this in google.
Does anyone know where these went, or better yet know where I can find out in the future in case I run into this problem yet again?
I know daemon() is a lazy way of doing things, and could write a proper way to daemonize this program myself (using fork and such), but using it is so convenient.
Linux man pages often include the header files needed for most functions try
or
Both of which probably say that you need
#include <unistd.h>