This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

STATIC_ASSERT and GCC (instead of Keil)

I'm bringing up ble_app_hrs as an eclipse project using gcc.

I'm running into an error in app_util.h, line 67:

#define STATIC_ASSERT(EXPR) typedef char static_assert_failed[(EXPR) ? 1 : -1]

The error is:

typedef 'static_assert_failed' locally defined but not used [-Werror=unused-local-typedefs] ble_app_hrs line 67, external location: ..../nrf51822/Include/app_common/app_util.h C/C++ Problem

I believe the instance of STATIC_ASSERT it's complaining about is in app_timer.c, line 1035:

STATIC_ASSERT(APP_TIMER_INT_LEVELS == 3);

QUESTION: what's up with this? Is there some kind of support I need to add so this mechanism will work correctly?

Parents
  • As far as I can see, this is a consequence of using GCC 4.8q4, in combination with -Werror, which turns all warnings into errors. Earlier versions of GCC have not given a warning on this construct, but it seems 4.8 does.

    The application note is written for a previous version of GCC, but there shouldn't be any problems by using later versions if you just solve this one. That can either be done by removing the -Werror flag from line 60 of Makefile.common, or fix app_util.h as follows:

    
    #define STATIC_ASSERT(EXPR) typedef char static_assert_failed[(EXPR) ? 1 : -1] __attribute__((unused))
    
    
Reply
  • As far as I can see, this is a consequence of using GCC 4.8q4, in combination with -Werror, which turns all warnings into errors. Earlier versions of GCC have not given a warning on this construct, but it seems 4.8 does.

    The application note is written for a previous version of GCC, but there shouldn't be any problems by using later versions if you just solve this one. That can either be done by removing the -Werror flag from line 60 of Makefile.common, or fix app_util.h as follows:

    
    #define STATIC_ASSERT(EXPR) typedef char static_assert_failed[(EXPR) ? 1 : -1] __attribute__((unused))
    
    
Children
Related