Compile *.c files as C++

Discussions concerning TrueSTUDIO for STM32 9.0.0 and later versions.

Moderators: Markus Girdland, Mattias Norlander

Noyb
Posts: 16
Joined: Fri Jan 26, 2018 2:17 pm

Compile *.c files as C++

Postby Noyb » Wed Jul 11, 2018 1:29 pm

Using "Atollic TrueSTUDIO for STM32 v9.0.1" ( https://atollic.com/ ) based on Eclipse 4.6.1 and CDT. Using the regular gnuarm compiler from https://developer.arm.com/open-source/g ... /downloads

atolic_20180711_000_152020.png
You do not have the required permissions to view the files attached to this post.

Noyb
Posts: 16
Joined: Fri Jan 26, 2018 2:17 pm

Re: Compile *.c files as C++

Postby Noyb » Wed Jul 11, 2018 1:30 pm

Had a "C" project that I converted to "C/C++" (using the "File \ New \ Others... \ C/C++ \ Convert to a C/C++ Project (Adds C/C++ Nature)" option), added "C/C++ General \ Files Types" ('*.c' as 'C++ Source File') and "C/C++ General \ Language Mappings" (for '(All)' interpret 'C Source File' and 'C++ Source File' as 'GNU C++'), clicked on "Enable project specific settings" in "C/C++ General" but to no avail.

atolic_20180711_001_151723.png

atolic_20180711_002_151734.png

atolic_20180711_003_151740.png
You do not have the required permissions to view the files attached to this post.

Noyb
Posts: 16
Joined: Fri Jan 26, 2018 2:17 pm

Re: Compile *.c files as C++

Postby Noyb » Wed Jul 11, 2018 1:32 pm

Before, when I compiled, there was only "GNU C" available, but now there is also "GNU C++" yet '*.c' files are still interpreted as 'C Source File' and targeted to the "GNU C" compiler despite both the "Files Types" and "Language Mappings" settings being correctly set.

atolic_20180711_005_151857.png

atolic_20180711_006_151912.png

atolic_20180711_007_151928.png
You do not have the required permissions to view the files attached to this post.
Last edited by Noyb on Wed Jul 11, 2018 1:35 pm, edited 1 time in total.

Noyb
Posts: 16
Joined: Fri Jan 26, 2018 2:17 pm

Re: Compile *.c files as C++

Postby Noyb » Wed Jul 11, 2018 1:32 pm

If I change the property of '*.c' files on a per-file basis, setting the "C/C++ Build \ Tool Chain Editor" to "C++ Compiler", it select the wrong "C++ Compiler" (the Atollic one and not the custom gnuarm one provided), even though being correctly identified as "Inherited from the project (GNU C++)" in "C/C++ General \ Language Mappings" but still set to "C Compiler" in "C/C++ Build \ Settings \ Tool Settings" and "GNU C" in "C/C++ General \ Path and Symbols \ Includes".

atolic_20180711_010_151955.png

capture_20180713_001_092746.png


I expected the advertised "project specific settings" to work actually.

Thanks for your attention.

PS : nope, I won't rename files or modify every file's property one by one, mostly because I want for some specific reasons to compile everything back using the "C Compiler". So I'd like just to change the "C/C++ General \ File Types" and "C/C++ General \ Language Mappings" settings.

BTW : I use a personal 'make' engine (Makeit) to just switch between the '-x c' and 'x c++' compilation flags without having them hard wired into the "GNU C" and "GNU C++" compilers' settings. And I also use VisualGDB under Visual Studio that allows the same trick on a per project basis ("Property Pages \ Configuration Properties \ C/C++ \ Advanced \ Compile As" : "/TP" or "/TC") that actually works like intended.
You do not have the required permissions to view the files attached to this post.


Return to “TrueSTUDIO for STM32 discussions”

Who is online

Users browsing this forum: uilter.witte and 0 guests