cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeIDE creating objects from a class source outside the project gives a compiler error. Also the constructor of this class is not called.

CasualNoises
Associate

I created a simple class in a folder outside the STM32CubeIDE:

class AT24C256Driver

{

public:

AT24C256Driver();

float get_m_foo();

private:

float m_foo;

};

I added the folder to the "C/C++ generals - Paths and Symbols" property of the project.

The AT24C256Driver.h and AT24C256Driver.cpp compile without an error.

Then in main.cpp I include the .h file, and so far the build is ok. I introduced syntax errors in both source files and the compiler complains, so the files are processed by the compiler.

But when creating an instance of this object, the constructor is not called. In the debugger the line containing the creation of an object is skipped.

  /* USER CODE BEGIN SysInit */

 AT24C256Driver mAT24C256Driver();

 /* USER CODE END SysInit */

When adding a call to a method, the compiler gives me an error telling me

"request for member 'get_m_foo' in 'mAT24C256Driver', which is of non-class type 'AT24C256Driver()'".

auto foo = mAT24C256Driver.get_m_foo();

Can anyone please tell me what's going wrong here.

0 REPLIES 0