2020-03-08 07:17 AM
Hi Folks,
Just starting off and have a question regarding the file extension of the 'main' file.
One of the options in creating the project is the targeted language: C or C++.
No matter which I choose the 'main' file is always main.c
I want to create main.cpp.
Any ideas about how to achieve this?
Thanks.
2020-03-08 07:41 AM
If you don't generate the project with Cube or CubeIDE, all your files can be C++.
TL;DR you don't want the Cube-generated main.c file to be C++. Neither the other Cube-generated files.
They better should stay .c, as created.
Add your own c++ files to the project and enjoy C++.
--pa
2020-03-08 07:42 AM
You didn't thought that mentioning IDE could be useful? Anyway, do you know how to rename a file?
But, if you are talking about CubeMX code generation, then:
2020-03-09 07:53 AM
Thanks for the replies folks,
Yes, I did omit to mention I was using STM32CubeIDE, sorry.
I didn't think it was as simple as renaming file from main.c to main.cpp
Seems an odd way to get things going, the IDE should do it for you given that it asked me 'C' or 'C++'
2020-03-09 10:58 AM
> the IDE should do it for you given that it asked me 'C' or 'C++'
The IDE yes, but the code generator (the Cube) currently can only generate plain C.
This isn't likely to change soon (and many customers would object. #metoo).
-- pa