You are not logged in.
so i have these lines of code:
#include <bits/pthreadtypes.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
void* thread_funch(pthread_mutex_t* interlock,int* thread) {
pthread_mutex_lock(interlock);
printf("testing thread %d",*thread);
pthread_mutex_unlock(interlock);
pthread_exit(NULL);
}
int main () {
printf("test");
pthread_mutex_t interlock=PTHREAD_MUTEX_INITIALIZER;
//thread initializer would go here
return 0;
} whenever i attempt to compile it using GNU gcc on terminal i get these errors:
In file included from test.c:2:
/usr/include/pthread.h:967:33: Error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
967 | extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
| ^~~~~~~~~~~~~~~~
| pthread_cond_t
/usr/include/pthread.h:968:39: Error: unknown type name ‘pthread_rwlockattr_t’
968 | const pthread_rwlockattr_t *__restrict
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:972:36: Error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
972 | extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock)
| ^~~~~~~~~~~~~~~~
| pthread_cond_t
/usr/include/pthread.h:976:35: Error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
976 | extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock)
| ^~~~~~~~~~~~~~~~
| pthread_cond_t
/usr/include/pthread.h:980:38: Error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
980 | extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock)
| ^~~~~~~~~~~~~~~~
| pthread_cond_t
/usr/include/pthread.h:986:40: Error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
986 | extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
| ^~~~~~~~~~~~~~~~
| pthread_cond_t
/usr/include/pthread.h:1023:35: Error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
1023 | extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock)
| ^~~~~~~~~~~~~~~~
| pthread_cond_t
/usr/include/pthread.h:1027:38: Error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
1027 | extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock)
| ^~~~~~~~~~~~~~~~
| pthread_cond_t
/usr/include/pthread.h:1033:40: Error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
1033 | extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
| ^~~~~~~~~~~~~~~~
| pthread_cond_t
/usr/include/pthread.h:1071:35: Error: unknown type name ‘pthread_rwlock_t’; did you mean ‘pthread_cond_t’?
1071 | extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock)
| ^~~~~~~~~~~~~~~~
| pthread_cond_t
/usr/include/pthread.h:1078:37: Error: unknown type name ‘pthread_rwlockattr_t’; did you mean ‘pthread_condattr_t’?
1078 | extern int pthread_rwlockattr_init (pthread_rwlockattr_t *__attr)
| ^~~~~~~~~~~~~~~~~~~~
| pthread_condattr_t
/usr/include/pthread.h:1082:40: Error: unknown type name ‘pthread_rwlockattr_t’; did you mean ‘pthread_condattr_t’?
1082 | extern int pthread_rwlockattr_destroy (pthread_rwlockattr_t *__attr)
| ^~~~~~~~~~~~~~~~~~~~
| pthread_condattr_t
/usr/include/pthread.h:1086:49: Error: unknown type name ‘pthread_rwlockattr_t’
1086 | extern int pthread_rwlockattr_getpshared (const pthread_rwlockattr_t *
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:1092:43: Error: unknown type name ‘pthread_rwlockattr_t’; did you mean ‘pthread_condattr_t’?
1092 | extern int pthread_rwlockattr_setpshared (pthread_rwlockattr_t *__attr,
| ^~~~~~~~~~~~~~~~~~~~
| pthread_condattr_t
/usr/include/pthread.h:1097:49: Error: unknown type name ‘pthread_rwlockattr_t’
1097 | extern int pthread_rwlockattr_getkind_np (const pthread_rwlockattr_t *
| ^~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:1103:43: Error: unknown type name ‘pthread_rwlockattr_t’; did you mean ‘pthread_condattr_t’?
1103 | extern int pthread_rwlockattr_setkind_np (pthread_rwlockattr_t *__attr,
| ^~~~~~~~~~~~~~~~~~~~
| pthread_condattr_t
/usr/include/pthread.h:1230:31: Error: unknown type name ‘pthread_spinlock_t’; did you mean ‘pthread_once_t’?
1230 | extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared)
| ^~~~~~~~~~~~~~~~~~
| pthread_once_t
/usr/include/pthread.h:1234:34: Error: unknown type name ‘pthread_spinlock_t’; did you mean ‘pthread_once_t’?
1234 | extern int pthread_spin_destroy (pthread_spinlock_t *__lock)
| ^~~~~~~~~~~~~~~~~~
| pthread_once_t
/usr/include/pthread.h:1238:31: Error: unknown type name ‘pthread_spinlock_t’; did you mean ‘pthread_once_t’?
1238 | extern int pthread_spin_lock (pthread_spinlock_t *__lock)
| ^~~~~~~~~~~~~~~~~~
| pthread_once_t
/usr/include/pthread.h:1242:34: Error: unknown type name ‘pthread_spinlock_t’; did you mean ‘pthread_once_t’?
1242 | extern int pthread_spin_trylock (pthread_spinlock_t *__lock)
| ^~~~~~~~~~~~~~~~~~
| pthread_once_t
/usr/include/pthread.h:1246:33: Error: unknown type name ‘pthread_spinlock_t’; did you mean ‘pthread_once_t’?
1246 | extern int pthread_spin_unlock (pthread_spinlock_t *__lock)
| ^~~~~~~~~~~~~~~~~~
| pthread_once_t
/usr/include/pthread.h:1254:34: Error: unknown type name ‘pthread_barrier_t’; did you mean ‘pthread_attr_t’?
1254 | extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
| ^~~~~~~~~~~~~~~~~
| pthread_attr_t
/usr/include/pthread.h:1255:40: Error: unknown type name ‘pthread_barrierattr_t’
1255 | const pthread_barrierattr_t *__restrict
| ^~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:1260:37: Error: unknown type name ‘pthread_barrier_t’; did you mean ‘pthread_attr_t’?
1260 | extern int pthread_barrier_destroy (pthread_barrier_t *__barrier)
| ^~~~~~~~~~~~~~~~~
| pthread_attr_t
/usr/include/pthread.h:1264:34: Error: unknown type name ‘pthread_barrier_t’; did you mean ‘pthread_attr_t’?
1264 | extern int pthread_barrier_wait (pthread_barrier_t *__barrier)
| ^~~~~~~~~~~~~~~~~
| pthread_attr_t
/usr/include/pthread.h:1269:38: Error: unknown type name ‘pthread_barrierattr_t’; did you mean ‘pthread_mutexattr_t’?
1269 | extern int pthread_barrierattr_init (pthread_barrierattr_t *__attr)
| ^~~~~~~~~~~~~~~~~~~~~
| pthread_mutexattr_t
/usr/include/pthread.h:1273:41: Error: unknown type name ‘pthread_barrierattr_t’; did you mean ‘pthread_mutexattr_t’?
1273 | extern int pthread_barrierattr_destroy (pthread_barrierattr_t *__attr)
| ^~~~~~~~~~~~~~~~~~~~~
| pthread_mutexattr_t
/usr/include/pthread.h:1277:50: Error: unknown type name ‘pthread_barrierattr_t’
1277 | extern int pthread_barrierattr_getpshared (const pthread_barrierattr_t *
| ^~~~~~~~~~~~~~~~~~~~~
/usr/include/pthread.h:1283:44: Error: unknown type name ‘pthread_barrierattr_t’; did you mean ‘pthread_mutexattr_t’?
1283 | extern int pthread_barrierattr_setpshared (pthread_barrierattr_t *__attr,
| ^~~~~~~~~~~~~~~~~~~~~
| it appears that some c libraries at /usr/include/ are either corrupt or missing , and if so where i can download them?, the errors are caused in the header.h files and not on the code itself,
searching for solution into the web didn't helped ether, I also attempted to possibly reinstall sources of the usr/include by reinstalling the packeges linux-headers , linux-api-headers, glibc, lib32-glibc and restarting the system without success
Last edited by tonimark (2024-01-29 23:40:25)
Offline
Generally speaking, if you want help with such problems, you should show the compiler command used. But in this case, the problem is simple: remove the first include line (with the "bits" header). Why was that even there in the first place?
Also, while not likely relevant to this concern, if you want that XOPEN_SOURCE macro to do anything, it needs to be defined before the includes. Though I'm not sure why it's there as you are not using any SUSv3-specific features (or even headers that have any SUSv3 feature tests).
Last edited by Trilby (2024-01-29 17:55:42)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
gcc -std=c11 test.cOffline
Generally speaking, if you want help with such problems, you should show the compiler command used. But in this case, the problem is simple: remove the first include line (with the "bits" header). Why was that even there in the first place?
Also, while not likely relevant to this concern, if you want that XOPEN_SOURCE macro to do anything, it needs to be defined before the includes. Though I'm not sure why it's there as you are not using any SUSv3-specific features (or even headers that have any SUSv3 feature tests).
even if the #define XOPEN_SOURCE is placed in the first line or removed nothing has changed
gcc -std=c11 test.c
gcc -std=c11 test2.c doesn't still doesn't change it , it still puts other errors and continues to display the same errors
Last edited by tonimark (2024-01-29 22:10:33)
Offline
$ cat a.c
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
void* thread_funch(pthread_mutex_t* interlock,int* thread) {
pthread_mutex_lock(interlock);
printf("testing thread %d",*thread);
pthread_mutex_unlock(interlock);
pthread_exit(NULL);
}
int main () {
printf("test");
pthread_mutex_t interlock=PTHREAD_MUTEX_INITIALIZER;
//thread initializer would go here
return 0;
}
$ gcc a.cOffline
Trilby wrote:Generally speaking, if you want help with such problems, you should show the compiler command used. But in this case, the problem is simple: remove the first include line (with the "bits" header). Why was that even there in the first place?
Also, while not likely relevant to this concern, if you want that XOPEN_SOURCE macro to do anything, it needs to be defined before the includes. Though I'm not sure why it's there as you are not using any SUSv3-specific features (or even headers that have any SUSv3 feature tests).
even if the #define XOPEN_SOURCE is placed in the first line or removed nothing has changed
Seriously, you ignore the part where he tells you what the problem is and focus on the part that says "while not likely relevant to this concern"
Online
even if the #define XOPEN_SOURCE is placed in the first line or removed nothing has changed
Seriously? That's what you took from my post? You confirmed that the one thing I said was not relevant to the currently problem was not relevant while also confirming that what I said was useless was useless... all the while completely ignoring the actual solution that was provided.
(edit: cross posted ... creating an echo)
Last edited by Trilby (2024-01-29 22:21:50)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Generally speaking, if you want help with such problems, you should show the compiler command used. But in this case, the problem is simple: remove the first include line (with the "bits" header). Why was that even there in the first place?
Also, while not likely relevant to this concern, if you want that XOPEN_SOURCE macro to do anything, it needs to be defined before the includes. Though I'm not sure why it's there as you are not using any SUSv3-specific features (or even headers that have any SUSv3 feature tests).
you were right the first include was wrong
Offline