开发者

How to avoid compiler warning when using PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP and -Wextra

开发者 https://www.devze.com 2023-03-15 12:28 出处:网络
I want to use GCC compiler option -Wextra in my project. But it causes problems with PTHREAD_RE开发者_如何转开发CURSIVE_MUTEX_INITIALIZER_NP.

I want to use GCC compiler option -Wextra in my project. But it causes problems with PTHREAD_RE开发者_如何转开发CURSIVE_MUTEX_INITIALIZER_NP.

The following code:

static pthread_mutex_t g_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;

Causes the following warning:

test.c:39: warning: missing initializer
test.c:39: warning: (near initialization for `g_mutex.__data.__nusers')

Is there any way to avoid that warning?

Gcc version is 3.4.5. and pthread version is 2.3.5.


With recent GCC versions (not the one you mention, I'm afraid) you can silence such warnings with the option -Wno-missing-field-initializers.

0

精彩评论

暂无评论...
验证码 换一张
取 消