Need to add a C++ file to a C project

Discuss how to use the features of Atollic TrueSTUDIO, including the editor, assembler, C/C++ compiler, linker, debugger, static code analysis and team collaboration tools.

Moderators: Markus Girdland, Mattias Norlander

Posts: 1
Joined: Mon Mar 04, 2019 2:07 am

Need to add a C++ file to a C project

Postby MichaelDennis » Mon Mar 04, 2019 2:30 am

I'd like to have both C and C++ files in the same TrueSTUDIO project.

I'm using an STMicroelectronics C based sample project, and it's quite complex, so I want to keep the project and add my C++ file to it. (In other words, I don't want to create a new project.)

When I add a C++ file to the project and do a build, the C++ file is ignored.

As a side note, I notice that the "Build Selected" files option (when I right click) is grayed out for the C++ file. (I have this feature enabled in my system, and it works with the C files in the project, but not with C++ files.)

Thank you for your help.

Posts: 117
Joined: Wed Apr 05, 2017 5:08 pm
Location: USA

Re: Need to add a C++ file to a C project

Postby frank_ee » Wed Mar 06, 2019 9:57 pm


This maybe related in how the project was made since it's a C project verse a C++ project.

Posts: 10
Joined: Wed Mar 20, 2019 7:06 am

Re: Need to add a C++ file to a C project

Postby Alexander_Zorn » Wed Mar 20, 2019 8:03 am

You have to Convert an existing project to a embedded C/C++ Project.

Close the project in project explorer. Right Click on the project you want to convert, use "New -> Convert to a C/C++ Project (adds C/C++ nature).

You can check if it has worked by having a look into the compiler settings. After the convert procedure a new chapter with c++ Compiler settings will appear in addition to assambler, c-compiler, linker, ...

best regards

Return to “Atollic TrueSTUDIO tool discussions”

Who is online

Users browsing this forum: No registered users and 2 guests