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 struct causing errors (Read 3628 times)
DrOldies
Junior Member
**
Offline


Posts: 16
Location: Iowa, USA
Joined: Feb 3rd, 2015
struct causing errors
Feb 3rd, 2015 at 1:32am
Print Post  
After installing Visual Studio and VisualMicro yesterday, I tried a simple sketch with a structure that I use for testing. Received the following debug errors. Any suggestions?

Compiling 'Structure_test' for 'Arduino Uno'
Structure_test.ino:6:1: error: 'RGB' does not name a type
:RGB getBlue();
:^
Structure_test.ino:7:1: error: 'RGB' does not name a type
:RGB printcolor (struct RGB m_rgb);
:^
Error compiling

// example about structures

struct RGB {
  int r;
  int g;
  int b;
} rgb, *pRGB;            //can create a struct or pointer to a struct

RGB printcolor (struct RGB m_rgb);            //MUST declare or get an undefined function error
RGB getBlue();

void setup(void){

//can fill struct members with data
  rgb.r = 3;
  rgb.g = 19;
  rgb.b = 255;

//can make a pointer to the struct
     RGB *p2RGB = & rgb;

//can assign a value through a pointer with the right arrow
     p2RGB -> r = 255;

//*pRGB is a pointer to a ITS OWN struct that was created at the top
  pRGB -> b = 12;
  printcolor (rgb);
}

//can declare structs in functions
RGB getBlue() {
     RGB color = { 0 , 0 , 255 };
     return color;
}

//can pass structs
//can return structs
RGB printcolor (struct RGB m_rgb){            //'struct' is optional but MUST match the above declaration
  m_rgb.r = 0;
  return m_rgb;
}

void loop(void){

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


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: struct causing errors
Reply #1 - Feb 3rd, 2015 at 2:01am
Print Post  
Hi,

If you install the latest beta of visual micro from earlier today I think it will resolve the problem as long as the signature of your methods match the prototypes that you have added.

I just tried your code and it works okay with the sp7 beta.

Thanks
« Last Edit: Feb 3rd, 2015 at 2:06am by Tim@Visual Micro »  
Back to top
IP Logged
 
DrOldies
Junior Member
**
Offline


Posts: 16
Location: Iowa, USA
Joined: Feb 3rd, 2015
Re: struct causing errors
Reply #2 - Feb 3rd, 2015 at 2:44am
Print Post  
This latest build solved the problem. The debugger is well worth the cost of this tool.
Thanks
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint