[Bug report] nrf cloud headers not working for C++

Hi,

I want to report a bug/issue with the NCS, is this the right place to do that?

We are compiling for C++, so when including headers like <net/nrf_cloud_coap.h> and <net/nrf_cloud_fota_poll.h>
there are some issues.

1. In net/nrf_cloud_fota_poll.h, the curly bracket of 
#ifdef __cplusplus
extern "C" {
#endif
is not closed in the end of the file.
2. In net/nrf_cloud_coap.h, there is an issue with having 
#ifdef __cplusplus
extern "C" {
#endif
before the #includes.
In the first case, it is possible to come around by adding a closing curling bracket after including the header.
In the second case, it is possible to come around by including these three in this exact order:
#include <zephyr/sys/cbprintf.h>
#include <zephyr/sys/cbprintf_cxx.h>
#include <net/nrf_cloud_coap.h>
Even if it's possible to come around, I wanted to report the bugs. Maybe there are some more, so it could be useful to compile for C++ in your tests perhaps.
Parents
  • Hello Nicholas,

    Thanks for taking the time for reporting this. Indeed this is an area of improvement in our test setup that we will look to address in the short term. The fix for the missing brackets is under review now and I found it in another library, so both should be fine soon.

    Regarding the libraries that you recommend to add to nrf_cloud_coap.h, seems to me that these are impacting the application more than the library, could you expand why you came up with these libraries in specific?

    Regards,

    Pascal.

  • Hi, thanks for the follow up.

    Regarding the libraries I had to include before including nrf_cloud_coap.h, is because of the inclusion of <cbprintf_cxx.h> furher down in the chain in <nrf_cloud_coap.h>. Because of the

    #ifdef __cplusplus
    extern "C" {
    #endif

    before the includes in <nrf_cloud_coap.h>, this won't work when compiling for C++ because of the templates used in <cbprintf_cxx.h>. They can't be compiled with C-linkage.

    That is the reason for including them before including <nrf_cloud_coap.h>, so they will be included with C++ name mangling. It's just a hacky solution.

    Btw; when compiling for C++, you will also find some other errors in some macros that is initializing structs in wrong order.

  • Ok, did you based your implementation in a sample or application? I could try to reproduce these errors then.

Reply Children
Related