Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Using nrfx drivers in C++ project

I'd like to use new nrfx drivers included in SDK 15. The problem is that I want to use C++ but nrfx header files are for C. The struct initializers can't be compiled as C++. For example

#define NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(hi_accu) \
    {                                               \
        .is_watcher = false,                        \
        .hi_accuracy = hi_accu,                     \
        .pull = NRF_GPIO_PIN_NOPULL,                \
        .sense = NRF_GPIOTE_POLARITY_LOTOHI,        \
    }

If this is included from .cpp file then I get:

SDK/modules/nrfx/drivers/include/nrfx_gpiote.h:77:5: sorry, unimplemented: non-trivial designated initializers not supported

nrfx_gpiote.h must be included from .c file not .cpp. So I'm going to end up with C and C++ mix. I'd like to avoid it, I want to have pure C++ project. But it seems not possible without rewriting SDK.

Related