I am currently trying to create a typedef to form a counting semaphore. Within the struct I have also a mutex, mutex attribute, condition variable, integer variable, and the methods to initialize the mutex elements. However, I keep getting a warning saying that "struct has no members" as well as an error saying that there is expected a "specifier-qualifier-list before 'pthread_mutex_t.'" I've looked at various examples online, but I've found nothing that explains what is being done wrong.
typedef struct counting_semaphore{
pthread_mutex_t M;
pthread_mutexattr_t attr;
pthread_mutexattr_init(&attr);
pthread_mutex_init(&M, &attr);
pthread_cond_t CV;
int value;
} countSem;
Aucun commentaire:
Enregistrer un commentaire