cancel
Showing results for 
Search instead for 
Did you mean: 

How to tell CubeIDE to compile specific *.c files with C++ compiler ?

ferro
Senior III

Hi,

How to tell CubeIDE to compile specific *.c files with C++ compiler ?

Changing suffix from *.c to *.cpp is not an option.

Thank you

4 REPLIES 4

@ferro wrote:

Changing suffix from *.c to *.cpp is not an option.

 

 Why not?  Seems misleading to name it .c when it's actually C++ ?

Anyhow, Could you just #include  the .c file in a .cpp file, and exclude the .c file from build?

Thanks for prompt reply.

No, files are writen in C and want to compile with C++ compiler.

"Could you just #include the .c file in a .cpp file, and exclude the .c file from build?"

Good idea but I perefere to set it as a flag in project properties. In Keil uVision IDE you right click on a file and set the  option to build it as C or C++.

If you right-click the file and choose 'Properties', there's this:

AndrewNeil_0-1733150322081.png

Looks like generic Eclipse ?

 

"If you right-click the file and choose 'Properties', there's this:"

Thanks. I set C++ there but adc.c is still treated as C.

ferro_1-1733152352370.png

 

Hm, Maybe clue is in what is writen at the bottom - seems that it is not per file.

 

ferro_0-1733152301338.png

If you can be bothered, could you try on your side, please ?