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

Why can't you add a new class in Segger ?

What hidden settings am I missing this time in the awful Segger studio ?

I get an error :

unknown type name class

When I compile with this new class called Test.cpp :

.cpp file:

#include "Test.h"


Test::Test()
{
    
} 

and the .h file :

#include <stdlib.h>
#include <stdio.h>

    class Test
    {
        
        
    public:
        
        Test();
     
    
        
    private:
        
         
    
    };

EDIT:

Not sure why people are down voting but I think it's a real problem, at least for a beginner .

if I change the main to main.cpp I get 250 errors, some of them are :

'->' cannot appear in a constant-expression
'&' cannot appear in a constant-expression
a cast to a type other than an integral or enumeration type cannot appear in a constant-expression

They are coming from C files used by Nordic (drivers and libraries). The project was an example project from SDK, and I'v added other things to it.

I asked some people about it on the net, and they said I can't just mixed C and C++ files, so for example:

//main.cpp
#include "flash.h"
int main(void){}

Will produce errors because I include C file in C++ file , where the C might not be properly writen for C++.

Some of the errors comes from lines like this :

NRF_GPIOTE_TASKS_OUT_0     = offsetof(NRF_GPIOTE_Type, TASKS_OUT[0]), /**< Out task 0.*/
Parents
  • Our SDK does not support C++ beyond the header guards in the drivers/libraries, and as far as I know this will not change in the near future. If you want to use C++, you need to spend the time it takes to convert the project into C++. There are much resources online that can help you solve any issues you could encounter. This is not a Nordic-specific issue, you would have encountered the same issues converting any C project into supporting C++.

Reply
  • Our SDK does not support C++ beyond the header guards in the drivers/libraries, and as far as I know this will not change in the near future. If you want to use C++, you need to spend the time it takes to convert the project into C++. There are much resources online that can help you solve any issues you could encounter. This is not a Nordic-specific issue, you would have encountered the same issues converting any C project into supporting C++.

Children
No Data
Related