Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the avr32-gcc C compiler for the C++ in Atmel Studio 6 without having to create a new project?

I have been migrating an IAR project to Atmel Studio 6. It took me some time to create all the folders and getting the right structure as it is in the IAR project. Then I realized that I created a C project when actually I have C++ code too. So the question is: How do I change the GCC compiler from C to C++ without having to create a new project?

I can not find any proper documentation about Atmel Studio 6. I addition, I don't see a way to change this parameter from the GUI.

I found out that I don't have to change the C for the C++ compiler. I have to use both. Each compiler does its job. avr32-gcc compiles C code and avr32-gcccpp compiles C++ code. Now the question is: How do I add a second compiler to the project?

I already have the avr32-gcc for C.

like image 238
Snake Sanders Avatar asked Oct 08 '13 07:10

Snake Sanders


People also ask

Is GCC compiler only for C?

GCC stands for GNU Compiler Collections which is used to compile mainly C and C++ language. It can also be used to compile Objective C and Objective C++.

Does GCC work with C?

GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, Fortran, Ada, D, and Go.


2 Answers

For those interested in the solution here is how to do it:

Open you project in Atmel Studio 6 Go to the solution explorer and right click on the project. Select "Unload project" Now the project should be colored in gray. Right click again on the project and select Edit.

You will see the xml code from the configuration and settings of the project.

Around line 50 more o less you will find these lines:

<Language>C</Language>
<ToolchainName>com.Atmel.AVRGCC32.C</ToolchainName>

And modify them as follow, changing the language:

<Language>CPP</Language>
<ToolchainName>com.Atmel.AVRGCC32.CPP</ToolchainName>

Right click on the project again and select reload project.

Now if you go to the properties of the project (CTRL + F7) you will see two compilers in the Toolchain. Now you can compile both C and C++ code.

like image 156
Snake Sanders Avatar answered Oct 28 '22 14:10

Snake Sanders


In addition to the accepted answer (which was super helpful, by the way), make sure that all properties for the project are the same as they were previously. After making the suggested change, most properties for the Linker, Assembler, Preprocessing Assembler, and Archiver that existed prior to the change no longer existed.

like image 29
Alan Kinnaman Avatar answered Oct 28 '22 15:10

Alan Kinnaman