Hi,
I'm using nRF5 SDK v. 14.0.0. I'm trying to pass a context pointer to the NRF_SDH_BLE_OBSERVER macro, but am running into compilation errors. I want to do something like:
void foo(some_struct_t* bar) {
NRF_SDH_BLE_OBSERVER(m_ble_observer, 1, ble_evt_handler, (void*)bar);
}
but this fails to compile with errors like:
../../../foo.c: In function 'foo':
../../../foo.c:383:60: error: initializer element is not constant
NRF_SDH_BLE_OBSERVER(m_ble_observer, 1, ble_evt_handler, (void*)bar);
^
../../../external/vendor/nRF5_SDK/components/softdevice/common/nrf_sdh_ble.h:90:18: note: in definition of macro 'NRF_SDH_BLE_OBSERVER'
.p_context = _context \
^
../../../foo.c:383:60: note: (near initialization for 'm_ble_observer.p_context')
NRF_SDH_BLE_OBSERVER(m_ble_observer, 1, ble_evt_handler, (void*)bar);
^
../../../external/vendor/nRF5_SDK/components/softdevice/common/nrf_sdh_ble.h:90:18: note: in definition of macro 'NRF_SDH_BLE_OBSERVER'
.p_context = _context \
^
ninja: build stopped: subcommand failed.
Is this intentional? Is it not possible to pass an arbitrary void* pointer as the context pointer to NRF_SDH_BLE_OBSERVER?
If instead of (void*)bar I pass the address of a file-scope static variable then it compiles, but this is not the behavior I want.
Thanks for any advice,
Robbie