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 Sketch compiles on Arduino IDE but fails with strange error on Visual Studio IDE (Read 2110 times)
Carlos Maia
Newbies
*
Offline


Posts: 2
Joined: Nov 23rd, 2017
Sketch compiles on Arduino IDE but fails with strange error on Visual Studio IDE
Nov 23rd, 2017 at 2:49pm
Print Post  
I have reduced a problem identified on a (long) sketch from a friend to the following example:

class AnyClass
{
public:
    int i;
    char a;
};

void AnyFunc(AnyClass x)
{
    int j;

    j = x.i;
}

void setup()
{

  /* add setup code here */

}

void loop()
{

    /* add main program code here */
    AnyClass y;
    AnyFunc(y);

}

This example doesn't do nothing usefull, but ilustrates  the problem. When compiled in Arduino IDE it will succeed; if compiled in Visual Studio IDE it will result in error. The behaviour is identical for a Arduino Nano board or for a ESP8266 board. The same using Visual Studio 2015 or Visual Studio 2017. It may have something different in the way the toolchain is invoked between the two IDE. I donĀ“t know the reason, eventually it will be something that you may want to investigate.

Best regards

Carlos Maia
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Sketch compiles on Arduino IDE but fails with strange error on Visual Studio IDE
Reply #1 - Nov 23rd, 2017 at 6:32pm
Print Post  
The arduino ide has a relatively new feature that inserts c++ prototypes into a more accurate location than it used too. Visual Micro still inserts at the beginning of the code.

You can either put your type/class definition in a .h file and then #include it or add the prototype yourself...

Code
Select All

//types
class AnyClass
{
public:
    int i;
    char a;
};

//prototypes
void AnyFunc(AnyClass x);

//methods
void AnyFunc(AnyClass x)
{
    int j;
 

  
Back to top
WWW  
IP Logged
 
Carlos Maia
Newbies
*
Offline


Posts: 2
Joined: Nov 23rd, 2017
Re: Sketch compiles on Arduino IDE but fails with strange error on Visual Studio IDE
Reply #2 - Nov 24th, 2017 at 10:24am
Print Post  
Thank you for the information, it solved the problem.

Best regards

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