Ambiguous reference for type pthread_mutex_t

I announced

pthread_mutex_t mutex=PTHREAD_MUTEX_INITIALIZER;

      

in the global space of my main program main.cpp.

However, when I try to refer to it in a function definition, for example

void foo(void)
{
    pthread_mutex_lock(&mutex);
    ...
}

      

the following error message appears:

reference to "mutex" is ambiguous

Any idea what's going on? If it helps, it gets recorded in xcode and I have included it in the program header.

+3


source to share


1 answer


It turns out that after I changed the name from mutex to mutex1, the errors were gone. I think because a mutex is a function somewhere ...



+2


source







All Articles