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 Compile errors when in debug mode (Read 6773 times)
Hank
Newbies
*
Offline


Posts: 4
Location: Northern Calofornia
Joined: May 29th, 2014
Compile errors when in debug mode
May 29th, 2014 at 9:10pm
Print Post  
When I build my project in debug mode I get two errors:

In function 'void setup()'
36: error: 'MicroDebug' was not declared in this scope

and

In function 'void loop()'
59: error: 'MicroDebug' was not declared in this scope

When I build it in release mode (or 'start without debugging'), I get no errors. I'm using AtmelStudio v6.2. I'm also new at C++, although I've programmed in C for 30 some years. Anybody have any ideas about what these errors mean??

Thank you!!

P.S. I noticed that a breakpoint was being set at the beginning of 'loop()', even if I deleted it and ran 'Start Debugging (F5)' again. If I put a breakpoint at 'setup()', and (optionally) disabled it, I would only get a single error:

In function 'void setup()'
30: error: 'MicroDebug' was not declared in this scope


===========================================

void setup()  [color=#ff0000]<-Line 30[/color]
{
     pinMode(MISO, OUTPUT);
     // turn on SPI in slave mode
     SPCR |= _BV(SPE);
     // clkpolarity = 0, clk_phase   = 1, on the MASTER side
     SPI.setDataMode (SPI_MODE0);  [color=#ff0000]<-Line 36[/color]
     // now turn on interrupts
     SPI.attachInterrupt();

     pinMode(SS, INPUT); digitalWrite(SS, HIGH);
     PCintPort::attachInterrupt(SS, &OnSSHigh, RISING);  // add more attachInterrupt code as required

     tft.reset();
     uint16_t id = tft.readID();
     tft.begin(id);
     //tft.begin(0x9328);
     tft.setRotation(1);
     engine.ChangeState(WelcomeState::Instance());

     Serial.begin(115200);
}

void loop()
{
     touchController.DetectTouch();
}

// SPI interrupt routine
ISR (SPI_STC_vect)  [color=#ff0000]<-Line 59[/color]
{
     communicator.AddByteToBuffer(SPDR);
}

« Last Edit: May 29th, 2014 at 9:27pm by Hank »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compile errors when in debug mode
Reply #1 - May 29th, 2014 at 9:19pm
Print Post  
Hi Hank,

The debugger works by injecting code into a temp copy of the sketch during the build process.

For some reason it has been unable to load the debug code and the debug compile has failed. 

Normally the debug normally only fails if invalid code is entered into a breakpoint condition however this sounds different. Currently, you should ignore the error line numbers when debug compile fails.

I suggest switching on "tools>options>visual micro>compiler>show build folder" and then attempting debug upload. The output will give you the folder where the temp build occurs. Please zip and email the .cpp with the same name as your sketch to info[at]visualmicro.com

We will then have a clearer idea of what failed.

I would ask more questions but the forum is due for a major upgrade over the next 24/48 hours and is running so slowly it's a pain. So emailing the zip will save the pain.
  
Back to top
IP Logged
 
Hank
Newbies
*
Offline


Posts: 4
Location: Northern Calofornia
Joined: May 29th, 2014
Re: Compile errors when in debug mode
Reply #2 - May 29th, 2014 at 9:31pm
Print Post  
Hi Tim,

Thanks, I'll do that...

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


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compile errors when in debug mode
Reply #3 - May 29th, 2014 at 9:55pm
Print Post  
Thanks for the file and the report. 

This is caused by a minor bug in Visual Micro workaround below. 

I am surprised that the sketch does not also fail to compile in release compile.

A standard part of the build process for arduino is to automatically create/inject prototypes for methods and also to automatically the respective mcu core which in this case is #include "arduino.h". All this happens in the temp file.

In debug mode Visual Micro also injects a #include "vm_dbg.h" for the debugger functions

To do this visual micro attempts to locate the first line of code and insert the prototypes and headers before it.

In the case of your sketch the first line of code is in the condition #ifdef USE_ADAFRUIT_SHIELD_PINOUT

So the result is something like the following. (I have removed your library includes from the top of the code for your privacy but you will see them in the .cpp you sent me)

Code
Select All
#include "library1.h"
#include "library2.h"

#ifdef USE_ADAFRUIT_SHIELD_PINOUT

#include "arduino.h"
#include <VM_DBG.h>

//
//
void OnSSHigh();
Adafruit_TFTLCD tft;

#else
 



(By the way, I notice your code has a manually added prototype for void OnSSHigh();. It's not needed but no problem)

The fix is simply to have some valid init code above the first #ifdef. No doubt the project might grow and a valid/useful variable might be defined but adding #define anyOldVar will work just as well (and not consume any memory).

Code
Select All
#include "library1.h"
#include "library2.h"

//this dummy added
#define anyOldVar 0

#ifdef USE_ADAFRUIT_SHIELD_PINOUT

Adafruit_TFTLCD tft;

#else
 



if you do that then the result in the temp build folder will be like this

Code
Select All
#include "library1.h"
#include "library2.h"

//this dummy added
#define anyOldVar 0

#include "arduino.h"
#include <VM_DBG.h>

//
//
void OnSSHigh();

#ifdef USE_ADAFRUIT_SHIELD_PINOUT
Adafruit_TFTLCD tft;

#else
 



 
Hopefully this can be fixed in the next release
« Last Edit: May 29th, 2014 at 9:57pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Hank
Newbies
*
Offline


Posts: 4
Location: Northern Calofornia
Joined: May 29th, 2014
Re: Compile errors when in debug mode
Reply #4 - May 29th, 2014 at 10:14pm
Print Post  
Hi Tim,

I added the '#define anyOldVar 0' before the '#ifdef Use_ADAF...' as you suggested, but still got the same errors. I also tried commenting out the 'void OnSSHigh()', and received this error: 43: error: 'OnSSHigh' was not declared in this scope...

Hank
  
Back to top
 
IP Logged
 
Hank
Newbies
*
Offline


Posts: 4
Location: Northern Calofornia
Joined: May 29th, 2014
Re: Compile errors when in debug mode
Reply #5 - May 29th, 2014 at 10:21pm
Print Post  
Tim,

I then moved the ''void OnSSHigh()" to replace the #define anyOldVar 0, and now it builds and the debugger is running (I think...). I'll get busy debugging the code now. Thanks!!!

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


Posts: 12188
Location: United Kingdom
Joined: Apr 10th, 2010
Re: Compile errors when in debug mode
Reply #6 - May 29th, 2014 at 11:30pm
Print Post  
Great, thanks for the update
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint