I am trying to use C++ with an nRF5 board, but I'm running into issues with the MDK, IAR (v8.40.2), and C++. When I try to include "nrfx_gpiote.h" in a .cpp file, I get the following errors (this is from the examples\peripherals\gpiote with main.c switched to main.cpp:
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_gpiote.h 84
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_gpiote.h 85
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_gpiote.h 86
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_gpiote.h 88
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_gpiote.h 89
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_gpiote.h 90
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_gpiote.h 91
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 129
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 130
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 131
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 132
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 133
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 134
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 136
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 137
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 138
Error[Pe028]: expression must have a constant value C:\nRF5_SDK_16.0.0\modules\nrfx\hal\nrf_ppi.h 139
Does anyone know why offsetof seems to be failing after the first offsetof in these files only with IAR and C++? I can't get a more minimal reproduction, as IAR will compile (with iccarm.exe -e --c++ test.cpp) even this:
#include <stddef.h>
extern "C"
{
typedef struct test
{
int a;
int b;
} test_t;
typedef enum
{
A = offsetof(test_t, a),
B = offsetof(test_t, b),
} test_field_t;
}