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 woes in Arduino C (Read 2852 times)
Harrzack
Member
***
Offline


Posts: 133
Location: Lindenwold, NJ USA
Joined: Dec 28th, 2012
STRUCT woes in Arduino C
Dec 2nd, 2013 at 9:00pm
Print Post  
I have what I believe to be a correct STRUCT construct but when I try and declare variables with it, Intellisense complains and my STRUCT vars are recognized.  Can anybody spot my error - code below
=Alan R.

Code
Select All
struct MenuItem {
	char name[16];
	int display;	// where 7-seg data for this menu item is held
	byte order;
	byte state;			// System State assgined to this menu is selected with RE switch
	byte ledpin;
};

MenuItem Count_menu;
MenuItem Speed_menu;
MenuItem Clear_menu;
MenuItem Step_menu;

***** The vars below are not being recognized, but the defines above are ****************
Count_menu.state = STATE_TDATA;

Count_menu.ledpin = MLED_COUNT;

Angle_menu.state = STATE_DDATA; 

  
Back to top
 
IP Logged
 
Dennis Mabrey
Junior Member
**
Offline


Posts: 19
Location: Branchburg, NJ
Joined: Oct 22nd, 2013
Re: STRUCT woes in Arduino C
Reply #1 - Dec 2nd, 2013 at 11:03pm
Print Post  
Where are you performing your assignments such as Count_menu.state = STATE_TDATA;?   In setup()?

Since you only posted the struct and some lines of code and not the actual code that is failing I was unable to make it fail.  If I make a define for STATE_TDATA and put the line Count_menu.state = STATE_TDATA; in setup() it works fine for me.

So for example the following code compiles and there are no intellisense errors:

Code
Select All
#define STATE_TDATA 42
#define MLED_COUNT   42
#define STATE_DDATA    42
struct MenuItem {
	char name[16];
	int display;	// where 7-seg data for this menu item is held
	byte order;
	byte state;			// System State assgined to this menu is selected with RE switch
	byte ledpin;
};

MenuItem Count_menu;
MenuItem Speed_menu;
MenuItem Clear_menu;
MenuItem Step_menu;

void setup() {
	Count_menu.state = STATE_TDATA;
	Count_menu.ledpin = MLED_COUNT;
}

void loop() {

} 


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