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

Compiler warnings/errors on unused variables

Following file: nRF5_SDK_15.2.0_9412b96/modules/nrfx/drivers/src/nrfx_saadc.c

I've now just add gcc specific unused attributes.

267c267
<     bool result;
---
>     bool result __attribute__((unused));
278c278,279
<             nrfx_err_t err_code = nrfx_saadc_channel_uninit(channel);
---
>             nrfx_err_t err_code __attribute__((unused));
>             err_code = nrfx_saadc_channel_uninit(channel);
408c409
<     bool result;
---
>     bool result __attribute__((unused));
591c592
<             bool result;
---
>             bool result __attribute__((unused));

This is just a work around. Best would be to check why gcc trips over NRFX_ASSERT.

Parents
  • Have you defined the preprocessor symbol DEBUG_NRF?

    NRFX_ASSERT() is mapped to ASSERT() in nrfx_glue.h, which only perform some useful operation if this symbol is defined:

    #if (defined(DEBUG_NRF) || defined(DEBUG_NRF_USER))
    #define NRF_ASSERT_PRESENT 1
    #else
    #define NRF_ASSERT_PRESENT 0
    #endif
    
    //#if defined(DEBUG_NRF) || defined(DEBUG_NRF_USER)
    
    /*lint -emacro(506, ASSERT) */ /* Suppress "Constant value Boolean */
    /*lint -emacro(774, ASSERT) */ /* Suppress "Boolean within 'if' always evaluates to True" */ \
    
    /** @brief Function for checking intended for production code.
     *
     * Check passes if "expr" evaluates to true. */
    
    #ifdef _lint
    #define ASSERT(expr)                                                          \
    if (expr)                                                                     \
    {                                                                             \
    }                                                                             \
    else                                                                          \
    {                                                                             \
        while (1);                                                                \
    }
    #else //_lint
    #define ASSERT(expr)                                                          \
    if (NRF_ASSERT_PRESENT)                                                       \
    {                                                                             \
        if (expr)                                                                 \
        {                                                                         \
        }                                                                         \
        else                                                                      \
        {                                                                         \
            assert_nrf_callback((uint16_t)__LINE__, (uint8_t *)__FILE__);         \
        }                                                                         \
    }
    
    #endif

  • My fault. Apparently I had a template file in one of the directories where NRFX_ASSERT was defined, but not defined as ASSERT. Thanks!

Reply Children
No Data
Related