1

I tried with following code. but it's not working. threads.h file is not detected by the compiler.

#include <threads.h>
#include <time.h>
#include <stdio.h>

int main(void)
{
    printf("Time: %s", ctime(&(time_t){time(NULL)}));
    thrd_sleep(&(struct timespec){.tv_sec=1}, NULL); // sleep 1 sec
    printf("Time: %s", ctime(&(time_t){time(NULL)}));
}

Error is as follows

nuwan2@nuwan:~/Desktop/test$ gcc main.c -o pro
main.c:1:21: fatal error: threads.h: No such file or directory
compilation terminated.
Nwn
  • 561
  • 2
  • 9
  • 33

0 Answers0