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 Error Compiling "expected unqualified-id before ..." (Read 10382 times)
Chris
Newbies
*
Offline


Posts: 2
Joined: Oct 27th, 2011
Error Compiling "expected unqualified-id before ..."
Oct 27th, 2011 at 9:19pm
Print Post  
I've imported an existing Arduino project (which compiled and ran fine from teh Arduino IDE) but teh .vsarduino.h file which is automatically created in Visual Studio contains spurious lines amongst the function prototypes which I think is confusing the compiler causing several "expected unqualified-id before 'else'" errors. 

The offending lines are of the form "else if ..." and have clearly been extracted from the source .pde files amongst the functions - as if the scope of the real functions wasn't being tracked correctly from the braces '{' & '}'.


Any suggestion as to what is wrong and what to try next please?
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Error Compiling "expected unqualified-id before ..."
Reply #1 - Oct 27th, 2011 at 9:50pm
Print Post  
that's a good one, amazing after the huge and complex projects we have tested with. going to be interesting to see the source. 

would you please post or email the zipped up project and also let me know where we can download any libraries

vm is using the same regex to extract the prototypes as the arduino ide java source uses. it must be a difference between .net and java regex. 

pls post or email the zipped files and we'll get it fixed thanks. if you email then the source will remain private.

info @ visualmicro.com

if it's easier just post an example of any single function that breaks. thanks
« Last Edit: Oct 27th, 2011 at 10:47pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Chris
Newbies
*
Offline


Posts: 2
Joined: Oct 27th, 2011
Re: Error Compiling "expected unqualified-id before ..."
Reply #2 - Nov 5th, 2011 at 12:26am
Print Post  
I've emailed the source to you, please let me know if you got it?  No problem posting it here if necessary, other than size, as it has already been made open source at http://ardunxt.googlecode.com/svn/trunk.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Error Compiling "expected unqualified-id before ..."
Reply #3 - Nov 5th, 2011 at 1:40pm
Print Post  
thanks. i'll take a look later. another user has reported a compiler problem if a class is defined in a .pde

if this is the issue, then an immediate fix that works in both arduino and vs is to move the class to a .cpp file with associated .h. don't forget to add an #include in the [mainsketch].pde but I am sure you know that Smiley
  
Back to top
IP Logged
 
Jimbob
Newbies
*
Offline


Posts: 1
Location: Sydney
Joined: Aug 7th, 2012
Re: Error Compiling "expected unqualified-id before ..."
Reply #4 - Jan 3rd, 2013 at 3:14am
Print Post  
It appears  this is still a problem. Simple code such as the below will not compile, as the "else if" instruction is interpreted as a new function and copied into the x.vsarduino.h header file.

void setup()
{}

void loop()
{}

int bill(void)
{
     if(1)
     {}
     else if (4)
     {}
     return 1;
}

Here is the x.vsarduion.h file
#define __AVR_ATmega2560__
#define __cplusplus
#define __builtin_va_list int
#define __attribute__(x)
#define __inline__
#define __asm__(x)
extern "C" void __cxa_pure_virtual() {}
void setup();
void loop();
int bill(void);
else if (4);

any ideas??
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Error Compiling "expected unqualified-id before ..."
Reply #5 - Jan 3rd, 2013 at 1:19pm
Print Post  
Oops forgot that one. The next major release has changed inthis area so will work.

For now I suggest adding braces to the If, or switching on "External Editor" in the Arduino IDE

Code
Select All
int bill(void)
{
     if(1)
     {}
     else
    {
      if (4)
         {}
     }
     return 1;
} 



The external editor option allows the same sketch to be opened in VS and Arduino at the same time. Edit/save in vs, then click upload in Arduino and it will upload the latest changes from VS.
« Last Edit: Jan 3rd, 2013 at 1:20pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint