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
Hot Topic (More than 8 Replies) 'MicroDebug' was not declared in this scope triggers cascading errors (Read 6821 times)
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
'MicroDebug' was not declared in this scope triggers cascading errors
Oct 18th, 2016 at 10:16pm
Print Post  
The attached sketch compiles OK in the Arduino IDE, but not in the VM IDE. It generates a series of "not declared" errors. 

The compiler verbose output is in the attached zip file.

Often, this type of error indicates a syntactic problem with braces or an unbalanced #if...#endif pairing, but I could not spot any such problems with this code. And the fact that it compiles OK in the Arduino IDE indicate some problem with the current compiler configuration. 

There is a past reference to this problem (see http://www.visualmicro.com/forums/YaBB.pl?num=1345757475), but that post says the problem was fixed years ago. Has it risen from the dead? Huh
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #1 - Oct 20th, 2016 at 8:32pm
Print Post  
Please switch the toolbar from Debug to Release so we can make a comparison with the Arduino IDE

If we determine that Visual Micro in Release mode works same as the Arduino IDE then it will save some time.

Thanks
  
Back to top
WWW  
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #2 - Oct 20th, 2016 at 8:51pm
Print Post  
I changed to "Release" instead of "Debug" but got the same results. See attached verbose output.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #3 - Oct 20th, 2016 at 9:01pm
Print Post  
Hi,

The error is completely different and unrelated to debug (see below). 

I need more info please.

Can you shed any light on where the missing variables are defined?

Are they defined in a .h? If so then can you confirm that the .h is included in the project via the solution explorer?

Can you confirm you understand how to include files in the project via the solution explorer and confirm you understand that the solution explorer has two views 1) shows all files on disk 2) show filtered view with just the files actually included in the project.

Sorry of the questions are basic but I am finding a lot of users who don't understand about including/excluding files from the project build process via the solution explorer

In fact the last release of visual micro automatically includes files that exist in the project folder for this reason.

Thanks

Code
Select All
DylanRobot.ino: In function void setup()

DylanRobot.ino: 319:25: error: 'timerIsr' was not declared in this scope
   Timer1.attachInterrupt(timerIsr)

DylanRobot.ino: 320:34: error: 'echoInterrupt' was not declared in this scope
   attachInterrupt(ECHO_INTERRUPT, echoInterrupt, CHANGE)

DylanRobot.ino: 331:9: error: 'center' was not declared in this scope
   center()

DylanRobot.ino: 335:13: error: 'showKeyMap' was not declared in this scope
   showKeyMap()

DylanRobot.ino: In function void loop()

DylanRobot.ino: 357:19: error: 'detectObstacle' was not declared in this scope
   detectObstacle()

DylanRobot.ino: 362:25: error: 'processSerialCommand' was not declared in this scope
   processSerialCommand()

DylanRobot.ino: 366:22: error: 'checkRemoteControl' was not declared in this scope
   checkRemoteControl()

DylanRobot.ino: 373:19: error: 'detectObstacle' was not declared in this scope
   detectObstacle()

DylanRobot.ino: 379:25: error: 'processSerialCommand' was not declared in this scope
   processSerialCommand()

DylanRobot.ino: In function void stop()

DylanRobot.ino: 420:11: error: 'stopLeft' was not declared in this scope
   stopLeft()

DylanRobot.ino: 421:12: error: 'stopRight' was not declared in this scope
   stopRight()

DylanRobot.ino: In function void forward(int)

DylanRobot.ino: 427:26: error: 'checkSpeed' was not declared in this scope
   speed = checkSpeed(speed)

DylanRobot.ino: 431:20: error: 'forwardRight' was not declared in this scope
   forwardRight(speed)

DylanRobot.ino: 432:19: error: 'forwardLeft' was not declared in this scope
   forwardLeft(speed)

DylanRobot.ino: In function void backward(int)

DylanRobot.ino: 438:26: error: 'checkSpeed' was not declared in this scope
   speed = checkSpeed(speed)

DylanRobot.ino: 442:21: error: 'backwardRight' was not declared in this scope
   backwardRight(speed)

DylanRobot.ino: 443:20: error: 'backwardLeft' was not declared in this scope
   backwardLeft(speed)

DylanRobot.ino: In function void spinLeft(int, int)

DylanRobot.ino: 449:26: error: 'checkSpeed' was not declared in this scope
   speed = checkSpeed(speed)

DylanRobot.ino: 453:20: error: 'backwardLeft' was not declared in this scope
   backwardLeft(speed)

DylanRobot.ino: 454:20: error: 'forwardRight' was not declared in this scope
   forwardRight(speed)

DylanRobot.ino: 456:19: error: 'forwardLeft' was not declared in this scope
   forwardLeft(speed)

DylanRobot.ino: In function void spinRight(int, int)

DylanRobot.ino: 460:26: error: 'checkSpeed' was not declared in this scope
   speed = checkSpeed(speed)

DylanRobot.ino: 464:21: error: 'backwardRight' was not declared in this scope
   backwardRight(speed)

DylanRobot.ino: 465:19: error: 'forwardLeft' was not declared in this scope
   forwardLeft(speed)

DylanRobot.ino: 467:20: error: 'forwardRight' was not declared in this scope
   forwardRight(speed)

DylanRobot.ino: In function void forwardLeft(int)

DylanRobot.ino: 502:26: error: 'checkSpeed' was not declared in this scope
   speed = checkSpeed(speed)

DylanRobot.ino: In function void forwardRight(int)

DylanRobot.ino: 519:26: error: 'checkSpeed' was not declared in this scope
   speed = checkSpeed(speed)

DylanRobot.ino: In function void backwardLeft(int)

DylanRobot.ino: 537:26: error: 'checkSpeed' was not declared in this scope
   speed = checkSpeed(speed)

DylanRobot.ino: In function void backwardRight(int)

DylanRobot.ino: 555:26: error: 'checkSpeed' was not declared in this scope
   speed = checkSpeed(speed)

DylanRobot.ino: In function void timerIsr()

DylanRobot.ino: 656:15: error: 'triggerPulse' was not declared in this scope
   triggerPulse();    \\ Schedule the trigger pulses

DylanRobot.ino: 657:22: error: 'motionOutputHandler' was not declared in this scope
   motionOutputHandler();      \\ Handle the motion detector output

DylanRobot.ino: In function void echoInterrupt()

DylanRobot.ino: 803:17: error: 'motionDetector' was not declared in this scope
   motionDetector()

DylanRobot.ino: In function void detectObstacle()

DylanRobot.ino: 926:12: error: 'whichway' was not declared in this scope
   whichway()

DylanRobot.ino: In function void checkRemoteControl()

DylanRobot.ino: 1097:41: error: 'getRemoteControlCommand' was not declared in this scope
   int command = getRemoteControlCommand()

DylanRobot.ino: 1101:39: error: 'processRemoteControlCommand' was not declared in this scope
   processRemoteControlCommand(command)

DylanRobot.ino: In function void processRemoteControlCommand(int)

DylanRobot.ino: 1198:14: error: 'showKeyMap' was not declared in this scope
   showKeyMap()

DylanRobot.ino: In function int getRemoteControlCommand()

DylanRobot.ino: 1221:34: error: 'getCommandIndex' was not declared in this scope
   int index = getCommandIndex(code)

DylanRobot.ino: 1223:38: error: 'showRemoteControlCommand' was not declared in this scope
   showRemoteControlCommand(code, index)

DylanRobot.ino: In function int getCommandIndex(long unsigned int)

DylanRobot.ino: 1238:36: error: 'showRemoteControlCommand' was not declared in this scope
   showRemoteControlCommand(code, i)
Error compiling sketch sources 

  
Back to top
WWW  
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #4 - Oct 24th, 2016 at 9:42pm
Print Post  
Tim,

I agree that the problem has nothing to do with debugging. It has to do entirely with the compile process. The VM compile process is finding "missing" variables. All of the "missing" variables are in the code, but compiled conditionally. There are four defines in lines 40-43 that control these options:

Code (C++)
Select All
#define REMOTE_CONTROL true			//	Implement Remote Control
#define OBSTACLE_DETECTION true		//	Implement Obstacle Detection
#define SERIAL_INPUT true			//	Implement Serial Input code
#define SHOW_DEMO false				//	Implement Demo Mode
 



The code compiles without error in the Arduino IDE, but not in the VS/VM IDE. The output from both IDEs is attached.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #5 - Oct 24th, 2016 at 9:44pm
Print Post  
The source code for the sketch is attached.
  

Please Register or Login to the Forum to see File Attachments
Back to top
 
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #6 - Oct 24th, 2016 at 9:49pm
Print Post  
Tim,

In this sketch, I am not including any other classes or .h files from the local folder. Everything is in the DylanRobot.ino sketch file. I am including some local and Arduino libraries (e.g. Servo.h), but all of the "missing variables" are in the DylanRobot.ino file. In fact, when I expand the Solution Explorer to show the contents of the .INO file, it shows all of the functions that it thinks are missing!
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #7 - Oct 24th, 2016 at 10:19pm
Print Post  
Thanks for the great example.

The problem is related to the last piece of outstanding work from all the arduino additions of the past months. 

Historically the function prototypes that are automatically inserted into the temp compiler version of the code, after the first valid code line. The first line is deduced using a regex expression so it was always prone to issues.

In your case the first line is incorrectly assumed to be
Code
Select All
#if !REMOTE_CONTROL && !OBSTACLE_DETECTION && !SERIAL_INPUT && !SHOW_DEMO 


You can get around the issue in one of two ways. The 1st suggestion is the easiest.

1) Solution 1 - Add the following int dummy = 0 near the top of the code (or add any of your own declaration(s) that are not pre-processor statements)
Code
Select All
//	There are (currently) four ways to control this robot:
//	1) Obstacle Detection
//	2) Remote Control
//	3) Serial Input
//	4) Fixed Demo
//
int dummy = 0;
 


2) Solution 2 - Add prototypes for methods prior to their first reference. For example: Add the timeIsr prototype at a valid location before it is first referenced in the code. (Visual Micro won't try to insert the prototype again if it finds it in the code with matching signature to the method)
Code
Select All
void timerIsr(); 


It can sometimes be confusing with the compile being in the temp folder but it is actually very easy to take a look if you ever need to. Open the following source in VS and you will see the prototypes are grayed out because they are in invalid location within an #if condition:- ot.cpp

Visual Micro will shortly be updated to manage the insertion of prototypes better. Adding prototypes to different locations in the code, instead of as a block, adds compelixity when it comes to determining drill down from compiler errors into .ino source code which is why it's taken a a few months to implement.
« Last Edit: Oct 24th, 2016 at 10:27pm by Tim@Visual Micro »  
Back to top
WWW  
IP Logged
 
Bob Jones
Full Member
***
Offline


Posts: 210
Location: Bellingham, WA
Joined: Dec 4th, 2015
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #8 - Oct 24th, 2016 at 11:20pm
Print Post  
Tim,

The dummy solution worked. I remember bumping into this problem before, so now I am feeling like the dummy Cheesy
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #9 - Oct 24th, 2016 at 11:42pm
Print Post  
It's a strange one because it's in hidden code 😀

I need to do it the new way because it affects others too
  
Back to top
WWW  
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12076
Location: United Kingdom
Joined: Apr 10th, 2010
Re: 'MicroDebug' was not declared in this scope triggers cascading errors
Reply #10 - Oct 25th, 2016 at 7:47pm
Print Post  
ps:

I am just pushing an update with a library discovery fix for old style Arduino libraries. 

Old style libraries optionally have a sub folder called "Utility" and Visual Micro was not hunting for #included libraries in the Utility folder.

This affected libraries such as Firmata which I noticed you are using. It means the SoftwareSerial library will be automatically discovered if applicable to the library code that is being compiled.

This means the following code that you have added to your project is no longer required. It's not a major issue,  of course your code is okay but I wanted to let you know things might be cleaner without it. (The Arduino IDE will already be doing what Visual Micro is now doing)

Code
Select All
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_ARC32) || (ARDUINO >= 100 && ARDUINO < 10500)
#include <SoftwareSerial.h>
#endif
 

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