Initializing NRF_BLE_QWR_DEF(qwr); results in a syntax error

I seem to be having weird issue upon initializing qwr module in my .cpp file

NRF_BLE_QWR_DEF(qwr); 

Doing so results in a syntax error

#define NRF_BLE_QWR_DEF(_name)                          \
    static nrf_ble_qwr_t _name;                         \
    NRF_SDH_BLE_OBSERVER(_name ## _obs,                 \ //  << ---- expected constructor or type conversion before '(' token
                         NRF_BLE_QWR_BLE_OBSERVER_PRIO, \
                         nrf_ble_qwr_on_ble_evt,        \
                         &_name)
Parents Reply Children
  • It seems to be telling that it's not possible in C++. Any way the same approach could be differently in C++? I see it's calling 

    NRF_SDH_BLE_OBSERVER
  • You could try to change the NRF_SDH_BLE_OBSERVER format, similar to how it's mentioned in the post I linked to. It's defined like this in nrf_sdh_ble.c, found in folder sdk_folder/components/softdevice/common:

    #define NRF_SDH_BLE_OBSERVER(_name, _prio, _handler, _context)                                      \
    STATIC_ASSERT(NRF_SDH_BLE_ENABLED, "NRF_SDH_BLE_ENABLED not set!");                                 \
    STATIC_ASSERT(_prio < NRF_SDH_BLE_OBSERVER_PRIO_LEVELS, "Priority level unavailable.");             \
    NRF_SECTION_SET_ITEM_REGISTER(sdh_ble_observers, _prio, static nrf_sdh_ble_evt_observer_t _name) =  \
    {                                                                                                   \
        .handler   = _handler,                                                                          \
        .p_context = _context                                                                           \
    }

Related