Skip to main content
T J
Senior III
December 25, 2016
Solved

I cant define a class in uV5

  • December 25, 2016
  • 1 reply
  • 1759 views
Posted on December 25, 2016 at 02:00

I set all the pins in CubeMx,

added a class to a .h file

renamed main.c to main.cpp

included the .h

and 'class' is undefined.

is there a switch in Cube for this ? 

using an '091

#class-undefined #uv5 #keil
This topic has been closed for replies.
Best answer by Tesla DeLorean
Posted on December 25, 2016 at 02:52

Needs to be a .CPP file that does the including, or you need to add the --cpp to enable compiler support. ie compile .C as C++

1 reply

Tesla DeLorean
Guru
December 25, 2016
Posted on December 25, 2016 at 02:52

Needs to be a .CPP file that does the including, or you need to add the --cpp to enable compiler support. ie compile .C as C++

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
T J
T JAuthor
Senior III
December 25, 2016
Posted on December 25, 2016 at 02:57

Hey it worked.

Project options c/c++ 

in Misc Controls

add --cpp

Tesla DeLorean
Guru
December 25, 2016
Posted on December 25, 2016 at 03:03

One has to watch for C++ name mangling, functions you wish to export to the vector table, for example, need extern 'C' prefix so they bind properly in the linker, rather than the WEAK ones. The SysTick Handler being one to watch in CubeMX/HAL

ie

extern 'C' void USART1_IRQHandler(void)

{

 ...

}

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..