fork download
  1. void *my_thread_process (void * arg)
  2. {
  3. int i;
  4.  
  5. pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
  6. pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
  7.  
  8. for (i = 0 ; i < 5 ; i++) {
  9. printf ("Thread %s: %d\n", (char*)arg, i);
  10. sleep (1);
  11. }
  12. }
  13.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function 'my_thread_process':
prog.c:5:3: warning: implicit declaration of function 'pthread_setcancelstate' [-Wimplicit-function-declaration]
   pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
   ^
prog.c:5:26: error: 'PTHREAD_CANCEL_ENABLE' undeclared (first use in this function)
   pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
                          ^
prog.c:5:26: note: each undeclared identifier is reported only once for each function it appears in
prog.c:5:49: error: 'NULL' undeclared (first use in this function)
   pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
                                                 ^
prog.c:6:3: warning: implicit declaration of function 'pthread_setcanceltype' [-Wimplicit-function-declaration]
   pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
   ^
prog.c:6:25: error: 'PTHREAD_CANCEL_ASYNCHRONOUS' undeclared (first use in this function)
   pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
                         ^
prog.c:9:5: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
     printf ("Thread %s: %d\n", (char*)arg, i);
     ^
prog.c:9:5: warning: incompatible implicit declaration of built-in function 'printf'
prog.c:10:5: warning: implicit declaration of function 'sleep' [-Wimplicit-function-declaration]
     sleep (1);
     ^
prog.c:12:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty