This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

sorry, unimplemented: non-trivial designated initializers not supported

i am working with Nrf52 + Visualgdb complier. nrf_drv_gpiote.h contains designated initializers which aren't supported by C++. I'm including all SDK headers inside an extern "C" {...} block but still get the following error when I use the GPIOTE_CONFIG_OUT_SIMPLE macro:

C:/Users/atif.shabbir/AppData/Local/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.nordic.nrf5x/nRF5x/components/drivers_nrf/gpiote/nrf_drv_gpiote.h:89:5: sorry, unimplemented: non-trivial designated initializers not supported. 
LEDBlink.cpp(42,43): note :  in expansion of macro 'GPIOTE_CONFIG_OUT_SIMPLE' 
nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);

is there any solution without changing the sdk files.

  • Well, C++ does not support designated initlializers and that's why GCC (that's the name of the compiler you are using) refuse to compile it. externs "C" just tells the compiler to use C linkage for all functions within the scope. I think you have a few options:

    a) Read the GCC manual to see if there is a way to enable designated initializers for C++ code

    b) Write some C functions that make use of the needed macros and call this C function from your C++ code.

    c) Do not use this makros. If you look at the macro you've named, it's trivial to replace it by a constexpr function that constructs a structure.

  • This is not allowed in C++ code (do a quick search on the internet for the error). Use the macro in a c file (make an init function in the c file and call it from the c++ file), or don't use the macro at all (see what it does and fill the struct fields yourself). Here is a similar case on this forum.

Related