2022-03-10 11:31 PM
Hi,
If I create a C++ STM32CubeIDE project the main generated file is a C file (main.c) and I have to rename this to main.cpp every time I update pinmux, drivers, etc in order to call C++ functions. I think it's not an usual workflow but could anyone confirm this?
gaston
2022-03-13 12:00 PM
Okay
2022-03-14 01:03 AM
Right. CMSIS/HAL/LL can live well in the common subset of C and C++, but adding real C++ user code easily is hindered by the wrong file name extension main.c, nothing more or less.
KnarfB
2022-03-14 11:24 AM
> In fact it is the opposite. Using extern C allows you to call C functions from C++.
And also declare C++ functions callable from C and global variables that can be referred from C.
2022-03-14 01:30 PM
I think we should better understand how this works:
https://www.geeksforgeeks.org/extern-c-in-c/
My suggestion is clear and I have also provided the case of MCUXpresso, an environment very similar to STM32Cube, which solves this issue easy and efficiently.
Please, any feedback from ST side?