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) enum data type giving red line (Read 5294 times)
groz
Junior Member
**
Offline


Posts: 22
Joined: Feb 21st, 2018
enum data type giving red line
Apr 17th, 2018 at 6:50pm
Print Post  
Why is there a red line and warning message (see attachment) when assigning an ENUM value to a variable of that type? Note: code compiles and functions correctly.

Board: Industruino D21G
Core: arduino15\packages\industruino\hardware\samd\1.0.1\cores\industruino
  

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


Posts: 12155
Location: United Kingdom
Joined: Apr 10th, 2010
Re: enum data type giving red line
Reply #1 - Apr 17th, 2018 at 7:12pm
Print Post  
It's best to paste the text of code instead of images then we can replicate more easily.

Code
Select All
typedef enum State {
	One,
	Two,
	Three
};

State state;

void setup()
{
	state = One;
}
 


« Last Edit: Apr 17th, 2018 at 7:19pm by Tim@Visual Micro »  
Back to top
IP Logged
 
groz
Junior Member
**
Offline


Posts: 22
Joined: Feb 21st, 2018
Re: enum data type giving red line
Reply #2 - Apr 17th, 2018 at 7:19pm
Print Post  
Will do in the future. 

If I put state.Off the redline moves to state and says: Enum State, type name is not allowed.
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12155
Location: United Kingdom
Joined: Apr 10th, 2010
Re: enum data type giving red line
Reply #3 - Apr 17th, 2018 at 7:20pm
Print Post  
Yes ignore my first answer I changed it.

Init state inside your setup
  
Back to top
IP Logged
 
groz
Junior Member
**
Offline


Posts: 22
Joined: Feb 21st, 2018
Re: enum data type giving red line
Reply #4 - Apr 17th, 2018 at 7:24pm
Print Post  
I've already have other instances in code of assigning the enum value to the variable but it comes back with same error. Like I said, the code does compile and function ? The difference is the red line moves under the = sign.

CONTROL_BOX_FAN_STATUS = Off;
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12155
Location: United Kingdom
Joined: Apr 10th, 2010
Re: enum data type giving red line
Reply #5 - Apr 17th, 2018 at 7:55pm
Print Post  
Not sure. This is possibly to do with a difference between VC++ intellisense and GCC
  
Back to top
IP Logged
 
groz
Junior Member
**
Offline


Posts: 22
Joined: Feb 21st, 2018
Re: enum data type giving red line
Reply #6 - Apr 17th, 2018 at 8:03pm
Print Post  
That might be it. I created the following simple C++ console routine and no red lines.

// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

enum state
{
     off,
     on,
};
state CONTROL_BOX_FAN_STATUS = off;

int main()
{
     CONTROL_BOX_FAN_STATUS = off;
     CONTROL_BOX_FAN_STATUS = on;
    return 0;
}
  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12155
Location: United Kingdom
Joined: Apr 10th, 2010
Re: enum data type giving red line
Reply #7 - Apr 18th, 2018 at 9:37pm
Print Post  
I can't get VS to show this as an intellisense error any more.

It might be that I upgraded from Visual Studio 15.5 to 15.6
  
Back to top
IP Logged
 
groz
Junior Member
**
Offline


Posts: 22
Joined: Feb 21st, 2018
Re: enum data type giving red line
Reply #8 - Apr 19th, 2018 at 3:48pm
Print Post  
Strange, I'm using 15.6.6. I did find that by changing the Board Type From Industruino D21G to 
Arduino/Genuino Uno the red line under the = sign goes away.

Is it possible for you to install this board and see if you can replicate the problem on your end.
Enter the Board Manager (Tools->Boards Manager), search for 'industruino' and install the 'Industruino SAMD Boards' package. Version 1.0.1
https://static.industruino.com/downloads/code/IndustruinoCores/IndustruinoSAMD/p...

Thanks

Here is a dump of my about info:

Microsoft Visual Studio Community 2017 
Version 15.6.6
VisualStudio.15.Release/15.6.6+27428.2037
Microsoft .NET Framework
Version 4.7.02556

Installed Version: Community

Visual C++ 2017   00369-60000-00001-AA121
Microsoft Visual C++ 2017

Arduino for Visual Studio   1.0
Arduino extension for Visual Studio. For more information please see docs, faq and forum at http://www.visualmicro.com
« Last Edit: Apr 19th, 2018 at 3:49pm by groz »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12155
Location: United Kingdom
Joined: Apr 10th, 2010
Re: enum data type giving red line
Reply #9 - Apr 19th, 2018 at 4:29pm
Print Post  
I have the board installed. I think we are at the whim of intellisense.

If you can find the definition that it is happy with I can probably add it to the intellisense-fixes of the next release.

edit: you are right I had been testing toolchains and had indutrial 101 selected instead ofthe D21. So yes there is an error now.
« Last Edit: Apr 19th, 2018 at 4:35pm by Tim@Visual Micro »  
Back to top
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12155
Location: United Kingdom
Joined: Apr 10th, 2010
Re: enum data type giving red line
Reply #10 - Apr 19th, 2018 at 4:41pm
Print Post  
I think I have found the issue. The intellisense fix for D21 removes a lot of system file "errors" but causes your example to fail.

I will look into it.
  
Back to top
IP Logged
 
groz
Junior Member
**
Offline


Posts: 22
Joined: Feb 21st, 2018
Re: enum data type giving red line
Reply #11 - Apr 19th, 2018 at 6:03pm
Print Post  
I did some more testing and added enum names to old style enum types AND tried creating an enum class as well. BOTH types now resolve properly and NO red lines.
Code (C++)
Select All
enum state
{
	On,
	Off
};

state Switch_State = state::Off;

enum class MyEnumClass
{
	one,
	two,
	three
};
MyEnumClass test_enumClass = MyEnumClass::three;

void setup()
{
  /* add setup code here */
}

void loop()
{
	Switch_State = state::On;
	test_enumClass = MyEnumClass::two;
  /* add main program code here */
}
 

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