fork download
  1. #include <time.h> #include<stdio.h> #include<omp.h>
  2. void main(){
  3. int i, j;
  4.  
  5.  
  6. omp_set_num_threads(4);
  7.  
  8. #pragma omp parallel
  9. {
  10. printf("The number of threads allocated are %d\n", omp_get_num_threads());
  11. int id = omp_get_thread_num();
  12. printf("The id is %d \n", id);
  13. }
  14. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:19: warning: extra tokens at end of #include directive
 #include <time.h> #include<stdio.h> #include<omp.h>
                   ^
prog.c:2:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
 void main(){
      ^~~~
prog.c: In function ‘main’:
prog.c:6:5: warning: implicit declaration of function ‘omp_set_num_threads’ [-Wimplicit-function-declaration]
     omp_set_num_threads(4);
     ^~~~~~~~~~~~~~~~~~~
prog.c:8:0: warning: ignoring #pragma omp parallel [-Wunknown-pragmas]
     #pragma omp parallel
 
prog.c:10:2: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
  printf("The number of threads allocated are %d\n", omp_get_num_threads());
  ^~~~~~
prog.c:10:2: warning: incompatible implicit declaration of built-in function ‘printf’
prog.c:10:2: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
prog.c:10:53: warning: implicit declaration of function ‘omp_get_num_threads’ [-Wimplicit-function-declaration]
  printf("The number of threads allocated are %d\n", omp_get_num_threads());
                                                     ^~~~~~~~~~~~~~~~~~~
prog.c:11:22: warning: implicit declaration of function ‘omp_get_thread_num’ [-Wimplicit-function-declaration]
             int id = omp_get_thread_num();
                      ^~~~~~~~~~~~~~~~~~
prog.c:3:12: warning: unused variable ‘j’ [-Wunused-variable]
     int i, j;
            ^
prog.c:3:9: warning: unused variable ‘i’ [-Wunused-variable]
     int i, j;
         ^
/home/YfuB8k/cctkhbh3.o: In function `main':
prog.c:(.text.startup+0xc): undefined reference to `omp_set_num_threads'
prog.c:(.text.startup+0x13): undefined reference to `omp_get_num_threads'
prog.c:(.text.startup+0x2a): undefined reference to `omp_get_thread_num'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty