Skip to main content
Glee.11
Associate III
Aug 26, 2020 12:24 AM UTC
Solved

Can stm32f103 use C++?

Hi All,

​

Can stm32f103 use C++? for programing not c.

​

I'm using stm32f103 / truestudio / cubemx.

​

I want to use some c++ ​grammer for programing.

If there's way to use c++

How i can use c++ in stm32f103?

regard.

​

​

This topic has been closed for replies.
TDK
TDKBest answer
Aug 26, 2020 1:04 AM UTC

Of course. The chip doesn't know what language you're using, it only sees the compiled code.

Most compilers are smart enough to realize *.cpp files are C++ while *.c files are C.

"If you feel a post has answered your question, please click ""Accept as Solution""."

4 replies

TDK
TDKBest answer
Aug 26, 2020 1:04 AM UTC

Of course. The chip doesn't know what language you're using, it only sees the compiled code.

Most compilers are smart enough to realize *.cpp files are C++ while *.c files are C.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Glee.11
Glee.11Author
Associate III
Aug 26, 2020 7:40 AM UTC

Thank you for your reply.

Is there any configuration for using c++?

or just use c++?

Tesla DeLorean
Guru
Aug 26, 2020 7:53 AM UTC

In Keil it is pretty straight forward, in GNU/GCC you need to make sure the linker script and startup code manage constructors properly.

​

The HAL code isnt in C++ so you'll need to interface with that.

​

The CPU ​doesn't care how you generate code, but in embedded you need to be significantly more aware of how the MCU and tools function and interact.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Oliver Sedlacek
Senior
Aug 26, 2020 8:00 AM UTC

IAR will compile C++ for that chip. They include good start up and linker files so it's simple to get running. The STM Cube examples usually have project files for IAR.