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

C++ compilation error with SDK 12.1.0 and 12.0.0: error: expected declaration before '}' token

Getting the error when trying to compile the C++ project with SDK 12.1.0:

In file included from .../components/softdevice/common/softdevice_handler/softdevice_handler.h:41:0,
                 from main.cpp:11:
.../components/softdevice/common/softdevice_handler/ant_stack_handler_types.h:78:1: error: expected declaration before '}' token
 }
 ^

The same with SDK 12.0.0.

Parents
  • As a Nordic employee, I can confirm this bug and have tested the patch.

    There is also a bug in bsp.h. Here is a patch:

    diff -rcN nRF5-SDK-12.1.0/examples/bsp/bsp.h nRF5-SDK-12.1.0/examples/bsp/bsp_fix.h
    *** nRF5-SDK-12.1.0/examples/bsp/bsp.h       Tue Oct  4 14:09:12 2016
    --- nRF5-SDK-12.1.0/examples/bsp/bsp_fix.h   Thu Nov  3 16:03:07 2016
    ***************
    *** 32,37 ****
    --- 32,41 ----
      #include <stdbool.h>
      #include "boards.h"
    
    + #ifdef __cplusplus
    + extern "C" {
    + #endif
    +
      #if !defined(BSP_DEFINES_ONLY) && !defined(BSP_SIMPLE)
      #include "app_button.h"
    
    ***************
    *** 45,54 ****
       */
      #ifdef BSP_UART_SUPPORT
      #include "app_uart.h"
    -
    - #ifdef __cplusplus
    - extern "C" {
    - #endif
      #endif // BSP_UART_SUPPORT
    
      #define BUTTON_ERASE_BONDING BSP_BUTTON_0_MASK
    --- 49,54 ----
    
Reply
  • As a Nordic employee, I can confirm this bug and have tested the patch.

    There is also a bug in bsp.h. Here is a patch:

    diff -rcN nRF5-SDK-12.1.0/examples/bsp/bsp.h nRF5-SDK-12.1.0/examples/bsp/bsp_fix.h
    *** nRF5-SDK-12.1.0/examples/bsp/bsp.h       Tue Oct  4 14:09:12 2016
    --- nRF5-SDK-12.1.0/examples/bsp/bsp_fix.h   Thu Nov  3 16:03:07 2016
    ***************
    *** 32,37 ****
    --- 32,41 ----
      #include <stdbool.h>
      #include "boards.h"
    
    + #ifdef __cplusplus
    + extern "C" {
    + #endif
    +
      #if !defined(BSP_DEFINES_ONLY) && !defined(BSP_SIMPLE)
      #include "app_button.h"
    
    ***************
    *** 45,54 ****
       */
      #ifdef BSP_UART_SUPPORT
      #include "app_uart.h"
    -
    - #ifdef __cplusplus
    - extern "C" {
    - #endif
      #endif // BSP_UART_SUPPORT
    
      #define BUTTON_ERASE_BONDING BSP_BUTTON_0_MASK
    --- 49,54 ----
    
Children
Related