Skip to main content
antonius
Associate III
Jun 30, 2019 4:16 AM UTC
Question

C++ library with STM32CubeMX ?

Dear Members,

Is it possible that I combine C language generated from STM32CubeMX with

C++ library ?

Any examples ?

Thanks =)

This topic has been closed for replies.

4 replies

Piranha
Principal III
Jun 30, 2019 8:37 AM UTC

Usually C++ code is put in separate *.cpp/*.hpp files. Add those files to the project and call their functions from C code.

antonius
antoniusAuthor
Associate III
Jun 30, 2019 9:20 AM UTC

I did that, but I can't compile with .cpp after I put --cpp on my compiler, it gave me a lot of errors, I use Keil for compiling.

What should I change to make it compatible between C and C++?

0690X000009YDEAQA4.jpg

Pavel A.
Jun 30, 2019 1:26 PM UTC

> it gave me a lot of errors

Which errors? No need to use --cpp, Keil's compiler will detect c++ file by .cpp extension.,

By the way, which Keil compiler are you using: V5 (armcc) or V6 (clang-like) ?

-- pa

antonius
antoniusAuthor
Associate III
Jun 30, 2019 1:38 PM UTC

I use uVision V5.26.2.0