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

Compile C++ code on Segger Embedded Studio

Hi everyone :D

 

  I'm not being able to compile a c++ code on segger embedded studio.

  The same code compiles with the Makefile provided in the SDK 14.2, but not with the segger solution on the same SDK.

  I change the main extension to cpp (ble_app_blinky example for the pca10040) and change the include on the segger solution. When it compiles, it gives me this errors on the following lines:
  - _Static_assert’ was not declared in this scope

  - expected constructor, destructor, or type conversion before ‘(’ token

#define STATIC_ASSERT_SIMPLE(EXPR)      _Static_assert(EXPR, "unspecified message")
#define STATIC_ASSERT_MSG(EXPR, MSG)    _Static_assert(EXPR, MSG)

  I read the forum here and changed the "_Static_assert" to static_assert due to c++/c differences, but then it doesn't compile again and gives me this errors on these lines

  - expected declaration specifiers or ‘...’ before ‘(’ token

#define PUSHED_HEADER_SIZE (sizeof(nrf_log_pushed_header_t)/sizeof(uint32_t))
#define STATIC_ASSERT_SIMPLE(EXPR)      static_assert(EXPR, "unspecified message")

  Maybe this is a configuration problem. Does anyone know how to configure segger properly?

Thanks,

Renato Morelli

Parents
  • Nordic Semiconductor doesn't have any official support for C++ in SES (or any other compiler) so you will have to do some of the error searching here yourself. The implementation of static asserts differ between compilers, so depending on your choice of compiler you need to change it. To get up and running quickly you may also look into just removing static asserts for now until you actually need them. They are only compile-time operations to sanity check various parameters, but you can just remove them all as shown below and the code will behave the same runtime.

     

    #define STATIC_ASSERT_SIMPLE(EXPR)
    #define STATIC_ASSERT_MSG(EXPR, MSG)

    The alternative is to figure out how to implement them in your compiler.

    Best regards,
    Rune Holmgren

Reply
  • Nordic Semiconductor doesn't have any official support for C++ in SES (or any other compiler) so you will have to do some of the error searching here yourself. The implementation of static asserts differ between compilers, so depending on your choice of compiler you need to change it. To get up and running quickly you may also look into just removing static asserts for now until you actually need them. They are only compile-time operations to sanity check various parameters, but you can just remove them all as shown below and the code will behave the same runtime.

     

    #define STATIC_ASSERT_SIMPLE(EXPR)
    #define STATIC_ASSERT_MSG(EXPR, MSG)

    The alternative is to figure out how to implement them in your compiler.

    Best regards,
    Rune Holmgren

Children
Related