質問

threads.h supports only dynamic mutex initialization with mtx_init().

Aparently there isn't any info on the internet regarding threads.h apart from: http://en.cppreference.com/w/c/thread.( I would really like to know if there is something more)

Does anyone know how is struct mtx_t in threads.h implemented? I would like to init the mutex statically like in pthreads ( PTHREAD_MUTEX_INITIALIZER ), to avoid calling initialization function every time at the start of the program.

役に立ちましたか?

解決

There is no ability of the C11 threads.h to initialize a mutex without calling mtx_init()

threads.h is implemented differently on different platforms - so knowing the implementation detail of how a mtx_t actually look like would't be of much use, you'd be just as well off using the native thread api if it exists, such as pthreads which does provide this ability.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top