Even if we change this to use the list of initializers in the constructor, it still doesn't work:
#include <pthread.h> struct foo { pthread_mutex_t test; foo() : test(PTHREAD_MUTEX_INITIALIZER) {} }; int main() { foo f; }
We can understand why it fails, and it can only be used for initialization in several contexts by looking at the output from the preliminary process:
struct foo { pthread_mutex_t test; foo() : test({ { 0, 0, 0, 0, 0, { 0 } } }) {} };
You cannot use nested curly braces to initialize as in C ++ 03, but it may be more interesting that C ++ 11 makes this syntax and use completely legal.
In the source code we will see a few more things:
A::A() { const pthread_mutex_t test = PTHREAD_MUTEX_INITIALIZER;
Flexo source share