Atmel Studio C++ - Page 1
Forum section: electronics / general

author: dan3460
author_rank: Frequent Contributor
timestamp: February 15, 2017, 08:41:28 pm
content: I have been working on Atmel Studio for a while, I'm happy with the development environment and probably will buy an Atmel ICE to be able to debug right on the chip. When I install Studio 7, getting familiar with it I read somewhere that C++ was no fully implemented and that classes was one of the things not done.Now I was reading on the Atmel site that Arduino projects are imported as a C++ project, also read in some forum (which I cannot find it again) a discussion of using classes while programing AVR. Maybe I imagine it. Does anyone have information on this?

author: f1rmb
author_rank: Regular Contributor
timestamp: February 15, 2017, 08:47:35 pm
content: Hi,Quote from: dan3460 on February 15, 2017, 08:41:28 pmI don't know Atmel Studio, but Arduino framework is C++.Just checked the homepage, at the bottom you can also read:"Studio 7 is the preferred IDP for developing and debugging all AVR and Atmel ? SMART applications. It gives you a seamless and easy-to-use environment to write, build and debug your applications written in C/C++ or assembly code."Cheers.---Daniel

author: julianhigginson
author_rank: Frequent Contributor
timestamp: February 15, 2017, 08:54:31 pm
content: just an idea - if you are not working on this professionally, consider a segger edu unit over Sam ice, it's similar price and works with all cortex m parts (though you aren't allowed to use it commercially, while you can use Sam ice commercially)Sent from my A0001 using Tapatalk

author: ataradov
author_rank: Super Contributor
timestamp: February 15, 2017, 09:01:27 pm
content: Classes are implemented, it is a very basic C++ feature.You probably heard about STL (Standard Template Library) not being implemented for AVR. This is true.STL is implemented on ARM to the extent that makes sense.

author: westfw
author_rank: Super Contributor
timestamp: February 15, 2017, 09:05:18 pm
content: QuoteWhat does "Atmel Studio does not fully implement C++ classes" actually mean? AS uses avr-g++, which surely supports classes (one of the few C++ features that the Arduino environment actually uses.) I guess it could mean that some of the IDE functionality (autocompete?) doesn't support classes in some way (?), but that also seems unlikely given that it uses Microsoft Visual Studio, which has supported C++ for quite a while.

author: dan3460
author_rank: Frequent Contributor
timestamp: February 15, 2017, 09:06:44 pm
content: Go this idea from this:http://www.atmel.com/webdoc/avrlibcreferencemanual/FAQ_1faq_cplusplus.htmlFirst dotted point:QuoteMaybe this is old?

author: ataradov
author_rank: Super Contributor
timestamp: February 15, 2017, 09:08:27 pm
content: Quote from: dan3460 on February 15, 2017, 09:06:44 pmNope, this is true. There is no STL in AVR-libc. STL is just too heavy weight for most AVR parts.On ARM STL is supported.

author: dan3460
author_rank: Frequent Contributor
timestamp: February 15, 2017, 09:11:26 pm
content: Quote from: julianhigginson on February 15, 2017, 08:54:31 pmWould it work with Atmel Studio?

author: ataradov
author_rank: Super Contributor
timestamp: February 15, 2017, 09:15:02 pm
content: Quote from: dan3460 on February 15, 2017, 09:11:26 pmIt will.But there is no limitation in Atmel-ICE. It is a standard CMSIS-DAP debugger, any tools that know about CMSIS-DAP will work with it. And supported parts depend on the PC tool, not on the debugger itself.

author: dan3460
author_rank: Frequent Contributor
timestamp: February 15, 2017, 09:20:51 pm
content: Quote from: ataradov on February 15, 2017, 09:08:27 pmSorry I'm old and I get confused pretty quickly. STL is the standard library correct? I understand that classes are implemented on the STL, i'm wrong? , so can I implement classes to use when programing a avr, let say a Atmega328?Sorry to look so stupid.

author: ataradov
author_rank: Super Contributor
timestamp: February 15, 2017, 09:26:47 pm
content: Quote from: dan3460 on February 15, 2017, 09:20:51 pmSTL is thishttps://en.wikipedia.org/wiki/Standard_Template_LibraryIt is a library that contains standard implementations of smart arrays, vectors, sorting algorithms, and all that stuff.Typically implementations are heavy weight and use dynamic memory allocation (malloc). None of this is suitable for typical AVR memory sizes.You can make your own classes, this is not a problem at all.

author: dan3460
author_rank: Frequent Contributor
timestamp: February 15, 2017, 10:08:32 pm
content: Thanks, I'll try it this evening. So you are going to tell me that I have been suffering not using classes, because I read the wrong thingataradov , I really appreciate your patience.

author: ataradov
author_rank: Super Contributor
timestamp: February 15, 2017, 10:11:04 pm
content: Quote from: dan3460 on February 15, 2017, 10:08:32 pmI would say so. The whole Arduino thing is C++ with classes, and it works fine.

author: HwAoRrDk
author_rank: Super Contributor
timestamp: February 15, 2017, 10:20:32 pm
content: Quote from: westfw on February 15, 2017, 09:05:18 pmIt does indeed support auto-complete for C++ classes.All the auto-complete, code snippet, refactoring, enhanced syntax highlighting, etc. is actually all provided by the 3rd-party Visual Assist add-in. Although AS is based on Visual Studio, because it's not using Microsoft's compiler, you don't actually get any of the usual Intellisense features, hence why Atmel had to bundle an add-in that provides that kind of stuff. In my opinion, Visual Assist isn't that great. It has limited code-formatting customisation, some annoyances in behaviour, and once or twice I have had it's 'rename' auto-refactoring feature mess up my code.

author: dan3460
author_rank: Frequent Contributor
timestamp: February 15, 2017, 10:25:46 pm
content: I just try it, indeed it works.Thanks everyone again.

author: westfw
author_rank: Super Contributor
timestamp: February 15, 2017, 10:41:36 pm
content: Code:STL is the standard library correct? I understand that classes are implemented on the STL? "Classes" are a language feature, and are supported by avr-g++ and AS.The STL is a set of *Standardized* classes implemented on top of the language itself. The usual STL makes heavy use of dynamic allocation (frequently not a good idea on small-RAM microcontrollers) and exception trapping (not implemented, perhaps not implementable, for AVR), so it's NOT present.The most obvious example is "Strings" - the STL (or is String considered part of libstdc++, rather than STL) implementation of Strings will let you do things like "S += 'a';" that will go and say "There isn't enough space in S to add another character, so I'll go realloc a new copy of S that has a bunch more space." So ... avr-g++ does not support Standard C++ Strings. But it supports enough that you can write your OWN C++ class to handle strings...