Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic 1.5.7 and C+11 (Read 4704 times)
Serenifly
Junior Member
**
Offline


Posts: 20
Joined: Jun 20th, 2013
1.5.7 and C+11
Jul 27th, 2014 at 11:52am
Print Post  
C+11 doesn't seem to work well with VM or I missed setting some option somewhere.

In the Arduino IDE I went to platform.txt and added -std=gnu++11 to compiler.cpp.flags

Now it recognizes this:
Quote:
constexpr int get_five() 
{      
     return 5;
}


This option appears to be read by Visual Micro too because I don't need to add it seperately in the command line options. VM behaves weirdly though.

Although it appears to compile, the constexpr keyword is marked as red with "error: this expression has no storage or class type specifier"

Something similar happens with ranges (similar to for each in other languages):
Quote:

int my_array[5] = {1, 2, 3, 4, 5};
for (int &x : my_array) 
{
    x *= 2;
}

This gives "error: references variable 'x' requires an initializer" in the editor, but again it compilers and it works correctly.

On the other hand, other features work fine. For example the nullptr constant or the auto keyword. That's all I tried though.

Do I need to set some switch in VM too or is this something that's just not supported right now?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: 1.5.7 and C+11
Reply #1 - Jul 27th, 2014 at 12:27pm
Print Post  
Hi,

You are right. For compile, upload etc. Visual Micro uses the build properties defined within the Arduino IDE configuration/cores. This gives a 100% compatible Arduino program.

The intellisense is a different system provided by the standard Visual Studio C++ system. Visual Micro attempts to maintain the VS project structure and properties in a way that provides as much intellisense as possible but it will never be perfect.

If you can establish any VS project properties that cause the intellisense to work better than please let us know and we will add to the vm system that manages the VS project.

Although infererior to VS in some ways, the Atmel Studio IDE might cater for this in a better. Again, like VS, the Atmel Studio intellisense is separate but it knows more about Gcc.
« Last Edit: Jul 27th, 2014 at 1:14pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Serenifly
Junior Member
**
Offline


Posts: 20
Joined: Jun 20th, 2013
Re: 1.5.7 and C+11
Reply #2 - Jul 27th, 2014 at 2:22pm
Print Post  
Yeah, I already noticed that Intellisense produces some other errors. It doesn't like the pgm_read_word() macro for example.

After doing some research, I guess I should have known this wouldn't work perfectly:
http://msdn.microsoft.com/en-us/library/hh567368.aspx
constexpr isn't even supported in VS2013 Shocked The range-based for loop on the other hand is supported in VS2012 but not in 2010.

VS2010 supports far less and I will get Intellisense errors on everything that VS doesn't know. And avr gcc now knows more C++11 than VS2010.


I'd like to avoid Atmel Studio though because I already use Visual Studio for C# and Visual C++. So having everything in one program is perfect. Smiley
Ah well, they're mostly nice-to-have instead of must-have features anyways.

That said, the stuff works. The fake errors are just confusing.
« Last Edit: Jul 27th, 2014 at 2:30pm by Serenifly »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12163
Location: United Kingdom
Joined: Apr 10th, 2010
Re: 1.5.7 and C+11
Reply #3 - Jul 27th, 2014 at 3:23pm
Print Post  
Makes sense. If you do find any settings or switches that will help it will be appreciated to hear about them. My c++ and gcc skills are weak and I never find time to learn it.

Thanks again

For others reading this post that have VS2010 installed. The Atmel download won't require the shell download (see atmel page). The Atmel Ide should closely resemble what you are used to because it is based on vs2010.  However, for the sake of a few red squiggles you might prefer to stick with VS 2010 Pro.

  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint