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

Build example project using C++11 with SEGGER_IDE failed

Hi, in these days I want use the new feature of C++11 in nrf52 project, so I rename the "main.c" file to "main.cpp"(ble_app_blinky project), select the C++11 compiler in project options dialog,

then start building, it failed and the infomation is: 

Look forward to your reply。

Parents
  • Hi,

    You can modify code a bit:

    #ifdef __GNUC__
    #ifdef __cplusplus
    #define STATIC_ASSERT_SIMPLE(EXPR)      extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])]
    #define STATIC_ASSERT_MSG(EXPR, MSG)    extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])]
    #else
    #define STATIC_ASSERT_SIMPLE(EXPR)      _Static_assert(EXPR, "unspecified message")
    #define STATIC_ASSERT_MSG(EXPR, MSG)    _Static_assert(EXPR, MSG)
    #endif
    #endif

    This will compile just fine.

Reply
  • Hi,

    You can modify code a bit:

    #ifdef __GNUC__
    #ifdef __cplusplus
    #define STATIC_ASSERT_SIMPLE(EXPR)      extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])]
    #define STATIC_ASSERT_MSG(EXPR, MSG)    extern char (*_do_assert(void)) [sizeof(char[1 - 2*!(EXPR)])]
    #else
    #define STATIC_ASSERT_SIMPLE(EXPR)      _Static_assert(EXPR, "unspecified message")
    #define STATIC_ASSERT_MSG(EXPR, MSG)    _Static_assert(EXPR, MSG)
    #endif
    #endif

    This will compile just fine.

Children
Related