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

Please can you add extern "C" as appropriate to your header files?

Hi,

Many of us use C++ rather than C (as it is superior in every way). When including many of the Nordic SDK header files it is necessary to wrap them in

extern "C" {
}

to get the proper linkage. Otherwise you get cryptic error messages like "impossible constraint in ‘asm’".

The standard practice to avoid this necessity is to add the extern wrapper to the header code where appropriate like this:

#ifdef __cplusplus
extern "C" {
#endif

// ...

#ifdef __cplusplus
}
#endif

But you haven't done that in any of the headers. Please can you do so?

Parents Reply
  • I am using SDK 15 and I noticed that nrf_pwr_mgmt.h is missing the C++ guards, so an easy fix for the next release.

    Also I had an issue with.. lines 205 in app_util.h

    #ifdef __GNUC__
    #define STATIC_ASSERT_SIMPLE(EXPR)      //_Static_assert(EXPR, "unspecified message")
    #define STATIC_ASSERT_MSG(EXPR, MSG)    //_Static_assert(EXPR, MSG)
    #endif
    

    The approach I have adopted is to define the state of the app using a set of vtables (classes) so C++ is essential.
    I am using the excellent SES and C++ 11
Children
No Data
Related