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 Able to compile in Arduino IDE but fail to compile in VS 2010 (Read 7606 times)
allan
Newbies
*
Offline


Posts: 4
Joined: Mar 13th, 2013
Able to compile in Arduino IDE but fail to compile in VS 2010
Mar 18th, 2013 at 4:34am
Print Post  
I have a sketch which is Able to compile in Arduino IDE but fail to compile in VS 2010.

struct S{      
     byte C;
     byte V;
     unsigned long d;
     unsigned long t;
};

void State(S s);

VS 2010 always complains:
'S' was not declared in this scope

Any help is appreciated.. Thanks
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Able to compile in Arduino IDE but fail to compile in VS 2010
Reply #1 - Mar 19th, 2013 at 12:56am
Print Post  
Hello,

I just added your code to a test project and it compiled first time.

Can you please post the full output from the compile

Also confirm or email your full program code. Email to info[at]visualmicro.com

Code
Select All
struct S{
     byte C;
     byte V;
     unsigned long d;
     unsigned long t;
};

void State(S s);

void setup()
{
}

void loop()
{
}
{ 




Thanks
  
Back to top
WWW  
IP Logged
 
allan
Newbies
*
Offline


Posts: 4
Joined: Mar 13th, 2013
Re: Able to compile in Arduino IDE but fail to compile in VS 2010
Reply #2 - Mar 20th, 2013 at 1:14am
Print Post  
Thanks for the reply.
Below is the code with compile error.

struct S{      
     byte C;
     byte V;
     unsigned long d;
     unsigned long t;
};

void State(S s);

S current[3];

void setup()
{



}



void loop()
{



}

void State(S stat)
{
     for(char i=0;i<3;i++){
    if(current[i].t==0){
      current[i].d = stat.d;
      break;
    }
  }
}
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Able to compile in Arduino IDE but fail to compile in VS 2010
Reply #3 - Mar 20th, 2013 at 7:03pm
Print Post  
Hi,

With your code I get errors in arduino 1.0.3 as well as Visual Studio

Code
Select All
sketch_mar20a:4: error: variable or field 'State' declared void
sketch_mar20a:4: error: 'S' was not declared in this scope
sketch_mar20a.ino: In function 'void State(S)':
sketch_mar20a.ino:23: warning: array subscript has type 'char'
sketch_mar20a.ino:24: warning: array subscript has type 'char' 



Can you please tell me which version of the arduino ide you are using so that I can see it work.

Thanks
  
Back to top
WWW  
IP Logged
 
allan
Newbies
*
Offline


Posts: 4
Joined: Mar 13th, 2013
Re: Able to compile in Arduino IDE but fail to compile in VS 2010
Reply #4 - Mar 21st, 2013 at 5:13am
Print Post  
I used below code:
Able to compile in ardiuno 1.03
But errors on visual studio


struct S{                              
  byte C;
  byte V;
  unsigned long d;
  unsigned long t;
};

void State(S stat);

S current[3];

void setup(){

}

void loop(){

}

void State(S stat)
{
  for(char i=0;i<3;i++){
    if(current[i].t==0){
       current[i].d = stat.d;
      break;
    }
  }
}
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12071
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Able to compile in Arduino IDE but fail to compile in VS 2010
Reply #5 - Mar 21st, 2013 at 11:50am
Print Post  
Thanks. I have found the problem and will resolve for the next release. You can probably workaround if required.

The problem is that Visual Micro is not detecting that you have added a prototype for
Code
Select All
void State(S stat); 

. By adding your own prototype you elect exactly where in the code the prototype should be placed. In this case your prototype uses a custom data type defined earlier in the same code file. 

Normally Arduino prototypes are placed above the code which is what vm is trying to do but because your prototype uses the custom data type this causes the error S is not declared.

The workaround is to place your custom type definitions in a .h instead of in the .pde or .ino

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