Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Incorrect coloring with custom enum macro

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
phildunstan Posted - May 09 2017 : 05:36:32 AM
Hi

We use a custom enum macro and Visual Assist gets the coloring wrong and incorrectly shows error squiggles. You can see the incorrect coloring in the switch statement where MyEnumType::VALUE1 and MyEnumType::VALUE2 are used. Those values also show the incorrect error squiggles.

Example Code:

#include <iostream>

#define ENUM(type, first, ...) struct EnumType##Info { 	enum EnumType { Start, first = 0, __VA_ARGS__, End, Count = End - Start }; };typedef Enum<EnumType##Info> type;


template<typename EnumInfo>
struct Enum : public EnumInfo
{
	typedef typename EnumInfo::EnumType EnumType;
	EnumType m_value;

	Enum() : m_value(EnumInfo::Start) {}
	Enum(EnumType value) : m_value(value) {}

	operator int() const { return int(m_value); }
};



ENUM(MyEnumType, VALUE0, VALUE1, VALUE2);

int main()
{
	MyEnumType x = MyEnumType::VALUE1;
	switch (x)
	{
	case MyEnumType::VALUE0:
		std::cout << "VALUE0" << std::endl;
		break;
	case MyEnumType::VALUE1:
		std::cout << "VALUE1" << std::endl;
		break;
	case MyEnumType::VALUE2:
		std::cout << "VALUE2" << std::endl;
		break;
	}
}






Visual Assist Info:
License: Suede (100-user license) Support ends 2018.04.06
VA_X.dll file version 10.9.2217.0 built 2017.04.26
DevEnv.exe version 15.0.26403.7 Enterprise
msenv.dll version 15.0.26403.7
Comctl32.dll version 6.10.14393.953
Windows 10 10.0 Build 14393
12 processors (x86-64, WOW64)
Language info: 1252, 0x409
1   L A T E S T    R E P L I E S    (Newest First)
feline Posted - May 09 2017 : 10:49:41 AM
Have you turned off IDE intellisense, perhaps via:

IDE tools menu -> Options -> Text Editor -> C/C++ -> Advanced -> Disable Database = True

Normally VA underlining is not active in VS2010 and above, since the IDE does its own C++ underlining. VA underlining is normally only active when IDE intellisense has been disabled.

In your macro, what is "Info" used for? You are using ##Info, but I am not seeing any definition, or parameter, to specify Info. Is this actually being used, or does the macro struct name always expand to "EnumTypeInfo"? This is important, because VA currently does not expand the ## in a macro, to generate the new names, so VA won't be understanding this macro properly. But, if the ##Info is not being used, I may be able to help find a work around for this.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000