Skip to main content
yujin
Associate II
October 10, 2022
Question

the main.c file generated with stm32cubeide should replace its fixname as .cpp

  • October 10, 2022
  • 9 replies
  • 2270 views

..

This topic has been closed for replies.

9 replies

Tesla DeLorean
Guru
October 10, 2022

Sorry what's the question?

With .cpp / C++ builds watch for name mangling and related linker issues. Also initialization of constructors prior to external memories being viable.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
yujin
yujinAuthor
Associate II
October 10, 2022

it work well if the suffix-name of main.c and stm32f3xx_it.c were set .cpp.

this is what the developers need.

I have given the advice times.

yujin
yujinAuthor
Associate II
October 10, 2022

let me clarify my questions again.

i want to develope with C++.

and STM32cubeide has the option to use c++ as major user developing language.

user's c++ code will mixed with c in main.c and stm32f3xx_it.c. but this want work unless main.c and stm32f3xx_it.c 's suffix name change to .cpp.

gbm
Principal
October 10, 2022

For the ISRs in stm32fxxx_it.c to work correctly, it's necessary to declare them as C functions. Same for some components of main.c. It's easier to keep these files as C rather than C++.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
yujin
yujinAuthor
Associate II
October 10, 2022

if so,how to use c++?

gbm
Principal
October 10, 2022

in a C++ module, declare a single function to be called by main as extern "C", this funcion will provide the interfce between main() and C++ code. It will call the other C++ stuff. Do the same for interrupts handled in C++.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
yujin
yujinAuthor
Associate II
October 10, 2022

how would you use c++ class in the main.c file?

yujin
yujinAuthor
Associate II
October 10, 2022

c++ is compatible with c,but c is not with c++.