Skip to main content
T J
Senior III
Dec 25, 2016 1:00 AM UTC
Solved

I cant define a class in uV5

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.
Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Dec 25, 2016 1:52 AM UTC
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 Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..

5 replies

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
Dec 25, 2016 1:52 AM UTC
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 Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
T J
T JAuthor
Senior III
Dec 25, 2016 2:57 AM UTC
Posted on December 25, 2016 at 02:57

Hey it worked.

Project options c/c++ 

in Misc Controls

add --cpp

Tesla DeLorean
Guru
Dec 25, 2016 3:03 AM UTC
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 Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..