The problem is that you are using the standard C99 compiler, but you are trying to access the POSIX extensions. To expose POSIX extensions, you must, for example, define _POSIX_C_SOURCE to 200809L (for the current standard). For example, this program:
#include <time.h> int main(void) { struct timespec reqtime; reqtime.tv_sec = 1; reqtime.tv_nsec = 500000000; nanosleep(&reqtime, NULL); }
will compile correctly and wait 1.5 seconds (1 second + 500000000 nanoseconds) with the following compilation command:
c99 main.c -D _POSIX_C_SOURCE=200809L
The _POSIX_C_SOURCE macro must be defined with the appropriate value for the available POSIX extensions.
Also the -Wall, -pedantic and -W options are not defined for the POSIX c99 command, they are more like the gcc commands for me (if they work on your system, then this is fine, just keep in mind that they are not portable to other POSIX systems )
source share