How am I supposed to initialize pthread mutexes?

Viewed 3962
#include <pthread.h>

pthread_mutex_t* mut;

int main()
{
        mut = PTHREAD_MUTEX_INITIALIZER;
}

The above code spits out error: expected expression before ‘{’ token.

#include <pthread.h>

pthread_mutex_t* mut = PTHREAD_MUTEX_INITIALIZER;

int main()
{

}

The above code spits out warning: braces around scalar initializer

So how am I supposed to initialize a mutex?

2 Answers
Related