Hi!
I'm compiling with 'GNU Tools ARM Embedded 4.9 2015q2/bin/arm-none-eabi-g++' and optimization -O0 and debug level -g3, nRF5 SDK version is nRF5_SDK_11.0.0_89a8197. When including ble_gap.h into my .cpp file I ran into the following error...
...\nRF5_SDK_11.0.0_89a8197/components/softdevice/s132/headers/ble_gatts.h: In function 'uint32_t sd_ble_gatts_descriptor_add(uint16_t, const ble_gatts_attr_t*, uint16_t*)': ...\nRF5_SDK_11.0.0_89a8197/components/softdevice/s132/headers/nrf_svc.h:69:6: error: asm operand 0 probably doesn't match constraints [-Werror]
...\nRF5_SDK_11.0.0_89a8197/components/softdevice/s132/headers/ble_gap.h:1419:1: note: in expansion of macro 'SVCALL' SVCALL(SD_BLE_GAP_AUTH_KEY_REPLY, uint32_t, sd_ble_gap_auth_key_reply(uint16_t conn_handle, uint8_t key_type, uint8_t const *p_key)); ^ ...\nRF5_SDK_11.0.0_89a8197/components/softdevice/s132/headers/nrf_svc.h:69:6: error: impossible constraint in 'asm'
The same goes for various other functions... 'uint32_t sd_ble_gap_lesc_dhkey_reply(uint16_t, const ble_gap_lesc_dhkey_t*)' 'uint32_t sd_ble_gap_keypress_notify(uint16_t, uint8_t)' 'uint32_t sd_ble_gap_lesc_oob_data_get(uint16_t, const ble_gap_lesc_p256_pk_t*, ble_gap_lesc_oob_data_t*)' ...
The following question led me to a solution: Problem including ble_advdata.h compiling with gcc
After digging deeper into different SDK versions sources I noticed that the solution mentioned in the questions above was included into nRF5_SDK_11.0.0_89a8197 but instead of uint16_t they used uint8_t.
Here is what "nrf_svc.h" Line 55-71 looks like in nRF5_SDK_11.0.0_89a8197:
...
#define GCC_CAST_CPP (uint8_t)
#else
#define GCC_CAST_CPP
#endif
#define SVCALL(number, return_type, signature) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
__attribute__((naked)) \
__attribute__((unused)) \
static return_type signature \
{ \
__asm( \
"svc %0\n" \
"bx r14" : : "I" (GCC_CAST_CPP number) : "r0" \
); \
} \
_Pragma("GCC diagnostic pop")
As the first argument of the functions causing the errors are all of type uint16_t it seems clear to me why the compiler complains about it.
The following changes to nrf_svc.h fixed the errors for me:
#define GCC_CAST_CPP (uint16_t)
Maybe Nordic can consider to incorporate that into the next SDK version?