STATIC_ASSERT_SIMPLE and STATIC_ASSERT_MSG redefinition cause GNU extension.

I am using SDK v16.0.0 with s140 softdevice. In app_util.h, there is STATIC_ASSERT_SIMPLE and STATIC_ASSERT_MSG definition decided by platform like __CC_ARM or __GNUC__. 

Things go wrong when I enable GNU extensions in Keil because I need zero length array feature, compiler version is 5, compile error like below:

..\..\..\..\..\..\components\libraries\util\app_util.h(225): warning: #47-D: incompatible redefinition of macro "STATIC_ASSERT_SIMPLE" (declared at line 219)
#define STATIC_ASSERT_SIMPLE(EXPR) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])]
..\..\..\..\..\..\components\libraries\util\app_util.h(226): warning: #47-D: incompatible redefinition of macro "STATIC_ASSERT_MSG" (declared at line 220)
#define STATIC_ASSERT_MSG(EXPR, MSG) extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])]

How to fix this issue? I don't want to change nrf SDK directly. Thanks!

Regards,

Jinzhao Young

  • When using GNU extensions in __CC_ARM then the only way I see is that you comment out the definition in app_util.h.

    The reason we give full SDK sources is for your application to to be able to manoeuvre complex configurations and changes as per your requirement. app_util.h clearly did not see the usecase of mising different extensions with Keil compiler, so I suggest you to make that changes in app_util.h without any hesitation.

Related