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

Programming nRF52 DK in C++ in Segger Embedded Studio

Hi.

I am writing software for my custom nRF52832 device but hardware wise it is identical to the nRF52 DK. 

I'm not that good of an embedded coder (or any kind of coder for that matter) and I am trying to integrate some i2c sensors on my device. 

But all the libraries of these sensors are written in C++, and are using objects and classes. Which C doesn't support.

I have managed to convert *some* of the code (in probably a very inefficient way) to plain C, but most of the code is beyond my capabilities. 

How can I code with C++ on this thing using Segger Embedded Studio? 

Any help would be greatly appreciated. 

- Usman

Parents
  • Hi Usman

    Any .cpp file should automatically be compiled using the C++ compiler, while any .c files will be compiled by the C compiler, so it should be possible to mix and match C and C++ code. 

    There might be library files in the SDK that will not compile in C++, because they use language features only available in C, but it should be possible to get around this by using C++ for your sensor libraries only.

    Have you tried to integrate any .cpp files in your project?

    If yes, did you face any issues?

    Best regards
    Torbjørn 

Reply
  • Hi Usman

    Any .cpp file should automatically be compiled using the C++ compiler, while any .c files will be compiled by the C compiler, so it should be possible to mix and match C and C++ code. 

    There might be library files in the SDK that will not compile in C++, because they use language features only available in C, but it should be possible to get around this by using C++ for your sensor libraries only.

    Have you tried to integrate any .cpp files in your project?

    If yes, did you face any issues?

    Best regards
    Torbjørn 

Children
Related