Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 Class members declared with macros

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
PSchmitt Posted - Jan 28 2019 : 10:49:56 PM
I have a case where I'm declaring class member variables with an optional inline default value using macros and __VA_ARGS__. However these variables aren't recognised by VA's intellisense - the default intellisense works fine (with a cpp.hint file).

The actual macros more involved, but I've boiled this down to a very simple test case which demonstrates the problem.

#define declare_var(type, name) type name;
#define declare_var_default(type, name, ...) type name __VA_ARGS__;

class DeclarationTestClass
{
	declare_var(int, test) // Shown in VA intellisense
	declare_var_default(int, testWithDefault, = 1) // Not shown in VA intellisense
};

So e.g. within the scope of DeclarationTestClass, "test" will be shown in VA's suggestions, but "testWithDefault" will not:



Note that it doesn't matter if members declared with declare_var_default actually provide a default or not (so
declare_var_default(int, test)
would have the same problem).

Also, members declared with either macro are not shown in the VA Outline view.

This is with VA 10.9.2302.0 and VS 2017.

Thanks
5   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Feb 02 2019 : 06:48:17 AM
Thank you for the update, I am glad this has helped. It took me a bit longer than I had intended to work out the fix, since I didn't realise there were two problems at work here, not just one.
PSchmitt Posted - Feb 01 2019 : 6:38:35 PM
I can confirm that's solved the problem for me, thanks for your help.
feline Posted - Feb 01 2019 : 09:16:28 AM
It turns out there are two separate problems at work here. I have been using VA Outline as a quick method to see if I have fixed the problem with the __VA_ARGS__ macro, but VA Outline is being confused by the lack of semi-colons at the end of the macro calls.

Just having two lines calling the "declare_var()" macro is enough to confuse VA Outline, unless you put the semi-colons at the end of the call. I know the semi-colons are not required here, since the macro is inserting them, but since we are handling the macros without getting to expand them all of the time, this can confuse us. This is a known bug:

case=88758

and the work around is to add the semi-colons.

Now I know this, I can now just focus on the listbox behaviour. I have moved the "declare_var_default" macro definition to a new header file, which looks like this:

// VA will NOT parse any part of this file after this block
#if 1 == 0
_asm {
#endif

#define declare_var_default(type, name, ...) type name __VA_ARGS__;

which will hide the problem macro from VA. But we still want VA to have some understanding of this macro. So I have also created a new, empty text file called "va_stdafx.h" and placed it in the same directory as my SLN file.

This file is not added to the solution. Our parser looks specifically for this special helper file, and parses it if found before parsing the solution. Here it can be used to add a simpler definition of the macro to VA's symbol database, so the file contains:

#define declare_var_default(type, name) type name;

please make sure the file ends with a blank line before saving it.

Having made these changes I then pressed the button:

VA Options -> Performance -> Rebuild symbol databases

and restarted the IDE. This makes sure VA will forget the "old" and now hidden definition of the macro, and instead use the version from the va_stdafx.h file. This should fix the listbox behaviour for you, but it won't fix VA Outline on its own.
PSchmitt Posted - Jan 30 2019 : 4:59:32 PM
Yes, the "declare_var_default" macro would normally be declared just once inside a header file, and it wouldn't really be a concern if VA is ignoring the whole header it's declared in.
feline Posted - Jan 29 2019 : 08:41:49 AM
I am seeing the same problem here. There is a known bug where out parser is confused by the use of the __VA_ARGS__ inside the macro:

case=78893

Is hiding the "declare_var_default" from VA an option? Is this macro declared just once, inside a header file that I can try and get VA to ignore? Or is this macro and ones similar to it declared in several different places?

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