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.

[edit] Changing the suffix from *.c to *.cpp is the least preferred option.

Thank you

25 REPLIES 25

@ferro wrote:

"Compiler options can be modified per file."

Where, how ?


As I showed earlier

As I said this does not work.

Thanks,

Andrew Neil suggested the same : 1st is suboptimal and 2nd does not work as this setting is at project level not a file. [Edit] It is supposed to be per file but seems to not work as described

ferro_0-1733320599254.jpeg

 

ferro
Senior III
 
 

‎2024-12-03 09:50 AM - edited ‎2024-12-03 10:26 AM

 

https://community.st.com/t5/stm32cubeide-mcus/how-to-tell-cubeide-to-compile-specific-c-files-with-c-compiler/m-p/749456/highlight/true#M32741

 

You can exclude the file from build and build it separately using a make file. You can run this command prior to building as an extra build step. Then add the o-file to the linker: https://community.st.com/t5/stm32-mcus-products/how-to-link-an-already-generated-object-file-in-existing-project/m-p/124589/highlight/true#M22428

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

Uf, this sounds scary. Seems the least annoying option is to change suffix to cpp, CubeIDE auto assign compiler based on that. And it's not possible to change it per file.


@ferro wrote:

Uf, this sounds scary. Seems the least annoying option is to change suffix to cpp, CubeIDE auto assign compiler based on that. And it's not possible to change it per file.


Your first post said it was impossible to change the file extension. And now it suddenly is?

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.

Yes.

Would rephrase it to "Changing suffix from *.c to *.cpp is the last option."

"Rightclick the file. Click properties. Click C/C++ General. Click Language mappings. Then select GNU C++ from the drop down menus."

Did you actually try this ? I did not get reply from Neil.


@ferro wrote:

"Rightclick the file. Click properties. Click C/C++ General. Click Language mappings. Then select GNU C++ from the drop down menus."

Did you actually try this ? I did not get reply from Neil.


Did YOU try this? I don't have your project. Since it says it overwrites project wide settings I think it only overwrites project wide defaults for that file. It wouldn't make sense if it would overwrite settings for other files. What would be the point otherwise? I only tried to see if my project had such an option, but I'm not going to modify it.

Kudo posts if you have the same problem and kudo replies if the solution works.
Click "Accept as Solution" if a reply solved your problem. If no solution was posted please answer with your own.