cancel
Showing results for 
Search instead for 
Did you mean: 

Main project file type.

JMazu.1
Associate III

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.

4 REPLIES 4
Pavel A.
Evangelist III

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

Piranha
Chief II

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:

https://community.st.com/s/question/0D50X0000BFER0CSQX/cube32-feature-request-need-to-handle-cpp-files

JMazu.1
Associate III

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++'

>  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