liang@liang-VirtualBox:~$ gcc -o library library.c -lpthread
library.c:10:19: error: parameter 1 (‘i’) has incomplete type
10 | void Student(void i) {
| ~^
library.c: In function ‘Student’:
library.c:12:8: error: stray ‘\342’ in program
12 | printf(���Student %i is entering …\n”, id);
| ^
library.c:12:9: error: stray ‘\200’ in program
12 | printf(���Student %i is entering …\n”, id);
| ^
library.c:12:10: error: stray ‘\234’ in program
12 | printf(��Student %i is entering …\n”, id);
| ^
library.c:12:21: error: expected ‘)’ before ‘is’
12 | printf(“Student %i is entering …\n”, id);
| ^
| )
library.c:12:34: error: stray ‘\342’ in program
12 | printf(“Student %i is entering ���\n”, id);
| ^
library.c:12:35: error: stray ‘\200’ in program
12 | printf(“Student %i is entering ���\n”, id);
| ^
library.c:12:36: error: stray ‘\246’ in program
12 | printf(“Student %i is entering ��\n”, id);
| ^
library.c:12:37: error: stray ‘\’ in program
12 | printf(“Student %i is entering …\n”, id);
| ^
library.c:12:39: error: stray ‘\342’ in program
12 | printf(“Student %i is entering …\n���, id);
| ^
library.c:12:40: error: stray ‘\200’ in program
12 | printf(“Student %i is entering …\n���, id);
| ^
library.c:12:41: error: stray ‘\235’ in program
12 | printf(“Student %i is entering …\n��, id);
| ^
library.c: At top level:
library.c:40:19: error: parameter 1 (‘arg’) has incomplete type
40 | void Manager(void arg) {
| ~^
library.c: In function ‘Manager’:
library.c:41:8: error: stray ‘\342’ in program
41 | printf(���Manager is waiting for the door to be opened.\n”);
| ^
library.c:41:9: error: stray ‘\200’ in program
41 | printf(���Manager is waiting for the door to be opened.\n”);
| ^
library.c:41:10: error: stray ‘\234’ in program
41 | printf(��Manager is waiting for the door to be opened.\n”);
| ^
library.c:41:18: error: expected ‘)’ before ‘is’
41 | printf(“Manager is waiting for the door to be opened.\n”);
| ^
| )
library.c:41:56: error: stray ‘\’ in program
41 | printf(“Manager is waiting for the door to be opened.\n”);
| ^
library.c:41:58: error: stray ‘\342’ in program
41 | printf(“Manager is waiting for the door to be opened.\n���);
| ^
library.c:41:59: error: stray ‘\200’ in program
41 | printf(“Manager is waiting for the door to be opened.\n���);
| ^
library.c:41:60: error: stray ‘\235’ in program
41 | printf(“Manager is waiting for the door to be opened.\n��);
| ^
library.c:41:11: warning: passing argument 1 of ‘printf’ from incompatible pointer type [-Wincompatible-pointer-types]
41 | printf(“Manager is waiting for the door to be opened.\n”);
| ^~~
| |
| void ()()
In file included from library.c:2:
/usr/include/stdio.h:332:43: note: expected ‘const char * restrict’ but argument is of type ‘void ()()’
332 | extern int printf (const char *__restrict __format, …);
| ~~~~~^~
library.c:41:11: warning: format not a string literal and no format arguments [-Wformat-security]
41 | printf(“Manager is waiting for the door to be opened.\n”);
| ^~~
library.c:42:33: warning: passing argument 2 of ‘pthread_cond_wait’ from incompatible pointer type [-Wincompatible-pointer-types]
42 | pthread_cond_wait(&door_opened, &mutex); // 等待门打开
| ^~
| |
| sem_t * {aka union [HTML_REMOVED] }
In file included from library.c:1:
/usr/include/pthread.h:987:38: note: expected ‘pthread_mutex_t * restrict’ {aka ‘union [HTML_REMOVED] * restrict’} but argument is of type ‘sem_t ’ {aka ‘union [HTML_REMOVED] ’}
987 | pthread_mutex_t __restrict __mutex)
| ~~~~~~^~~
library.c:43:8: error: stray ‘\342’ in program
43 | printf(���Manager open door.\n”);
| ^
library.c:43:9: error: stray ‘\200’ in program
43 | printf(���Manager open door.\n”);
| ^
library.c:43:10: error: stray ‘\234’ in program
43 | printf(��Manager open door.\n”);
| ^
library.c:43:18: error: expected ‘)’ before ‘open’
43 | printf(“Manager open door.\n”);
| ^~~
| )
library.c:43:29: error: stray ‘\’ in program
43 | printf(“Manager open door.\n”);
| ^
library.c:43:31: error: stray ‘\342’ in program
43 | printf(“Manager open door.\n���);
| ^
library.c:43:32: error: stray ‘\200’ in program
43 | printf(“Manager open door.\n���);
| ^
library.c:43:33: error: stray ‘\235’ in program
43 | printf(“Manager open door.\n��);
| ^
library.c:43:11: warning: passing argument 1 of ‘printf’ from incompatible pointer type [-Wincompatible-pointer-types]
43 | printf(“Manager open door.\n”);
| ^~~
| |
| void ()()
In file included from library.c:2:
/usr/include/stdio.h:332:43: note: expected ‘const char * restrict’ but argument is of type ‘void ()()’
332 | extern int printf (const char *__restrict __format, …);
| ~~~~~^~
library.c:43:11: warning: format not a string literal and no format arguments [-Wformat-security]
43 | printf(“Manager open door.\n”);
| ^~~
library.c:46:39: warning: passing argument 2 of ‘pthread_cond_wait’ from incompatible pointer type [-Wincompatible-pointer-types]
46 | pthread_cond_wait(&all_students_left, &mutex); // 等待所有学生离开
| ^~
| |
| sem_t * {aka union [HTML_REMOVED] }
In file included from library.c:1:
/usr/include/pthread.h:987:38: note: expected ‘pthread_mutex_t * restrict’ {aka ‘union [HTML_REMOVED] * restrict’} but argument is of type ‘sem_t ’ {aka ‘union [HTML_REMOVED] ’}
987 | pthread_mutex_t __restrict __mutex)
| ~~~~~~^~~
library.c: In function ‘main’:
library.c:65:49: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
65 | pthread_create(&students[i], NULL, Student, (void)i);
| ^
library.c:65:40: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [-Wincompatible-pointer-types]
65 | pthread_create(&students[i], NULL, Student, (void)i);
| ^~~
| |
| void ()()
In file included from library.c:1:
/usr/include/pthread.h:200:15: note: expected ‘void * ()(void )’ but argument is of type ‘void ()()’
200 | void (__start_routine) (void *),
| ~~^~~~~
library.c:70:32: warning: passing argument 3 of ‘pthread_create’ from incompatible pointer type [-Wincompatible-pointer-types]
70 | pthread_create(&manager, NULL, Manager, NULL);
| ^~~
| |
| void ()()
In file included from library.c:1:
/usr/include/pthread.h:200:15: note: expected ‘void * ()(void )’ but argument is of type ‘void ()()’
200 | void (__start_routine) (void *),
| ~~^~~~~~~~~
liang@liang-VirtualBox:~$ gcc-o library library.c-lpthread
Command ‘gcc-o’ not found, did you mean:
command ‘gcc-8’ from deb gcc-8 (8.4.0-3ubuntu2)
command ‘gccgo’ from deb gccgo (4:10.0-1ubuntu2)
command ‘gcc-7’ from deb gcc-7 (7.5.0-6ubuntu2)
command ‘gcc-9’ from deb gcc-9 (9.4.0-1ubuntu1~20.04.2)
Try: sudo apt install [HTML_REMOVED]