implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration]

#define _GNU_SOURCE
#include <unistd.h>

int main() {
    usleep(1000);
    return 0;
}

Explanation:

  1. #define _GNU_SOURCE: Defines the _GNU_SOURCE macro before including any header file. This macro is used to enable additional features or extensions specific to the GNU system.

  2. #include <unistd.h>: Includes the header file unistd.h, which provides access to the POSIX operating system API, including the usleep function.

  3. int main() {: Starts the definition of the main function, the entry point of the C program.

  4. usleep(1000);: Calls the usleep function with an argument of 1000 microseconds, causing the program to sleep or delay execution for the specified amount of time.

  5. return 0;: Exits the main function with a return value of 0, indicating successful execution of the program.