Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
User name:
Password:
Save Password
Forgot your password?

 All Forums
 Visual Assist
 Feature Requests
 Problem with Boost foreach
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

xxluda
Senior Member

29 Posts

Posted - Feb 19 2009 :  08:23:18 AM  Show Profile  Reply with Quote
Hello

We're using boost foreach macros in our projects, but Visual Assist doesn't handle it well.

In StdAfx.h we have :

#include <boost/foreach.hpp>
#define foreach BOOST_FOREACH


And in code we have for example :

std::list<stObjectInfo> &lstObjs = ...;
foreach ( stObjectInfo &objInfo, lstObjs )
{
  ...
  objInfo.
}


When I want to VA show me suggestion list for object objInfo, VA show msg "Type of expression to the left of . or -> is not class struct or union."
I know that templates under the macro BOOST_FOREACH is realy complex, but isn't there any way to tell VA that objInfo has some type ? (for example in comments) :

foreach ( stObjectInfo &objInfo, lstObjs ) //VA: stObjectInfo &objInfo



Thanks for reply
Ludek Vodicka

Edited by - xxluda on Feb 19 2009 08:26:51 AM

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 22 2009 :  1:07:53 PM  Show Profile  Reply with Quote
Visual Assist isn't parsing macros recursively by default. So Visual Assist don't know what is BOOST_FOREACH after foreach in this line:

#define foreach BOOST_FOREACH

To turn on recursive macro parsing, just follow the steps here:

http://docs.wholetomato.com?W363

You may need to rebuild your symbol databases after this, by pressing this button:

VA Options -> Performance -> Rebuild symbol databases

Please let me know if it doesn't help.

Edited by - accord on Feb 22 2009 1:11:04 PM
Go to Top of Page

xxluda
Senior Member

29 Posts

Posted - Feb 27 2009 :  11:07:10 AM  Show Profile  Reply with Quote
Hello,

I try to set registry keys `LimitMacro` and `LimitMacroParsing` to yours recomanded values, but foreach macro still not works.

But as new side effect of macro recursive parsing, when I editing our Unit-tests (also written by boost macros) IDE is realy slow (sometimes I'am not able to write more than one char per second).

So, I want to ask again, isn't there any way to help VA parser with type and variable identification ? Or, Is there any chance to implement these helpers ? (I don't known how dificult it could be)

Thanks
Ludek Vodicka

Ludek Vodicka
Skipper Chief developer www.skipper18.com
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Feb 27 2009 :  3:53:57 PM  Show Profile  Reply with Quote
Turn off this recursive macro stuff.

You can help VA to parse difficult code by placing a simplified version of a macro or class into its stdafx.h:

http://docs.wholetomato.com?W302

It is parsed and seen only by VA. I have prepared a macro for your specific case:

#define foreach(x, y) x;

Just put it into this stdafx.h, so VA's parser will think you have an object definition, so

foreach ( stObjectInfo &objInfo, lstObjs )
{
  ...
  objInfo.
}

will expand to

stObjectInfo &objInfo;
{
   ...
    objInfo.
}

so listboxes should contain the correct class members. I've tested this approach and it worked for me.

Edited by - accord on Feb 27 2009 4:03:18 PM
Go to Top of Page

xxluda
Senior Member

29 Posts

Posted - Feb 28 2009 :  04:21:50 AM  Show Profile  Reply with Quote
Hello
Your solution works perfect, thanks a lot. Also thanks for detailed explaination, which helps us in other VA parsing problems whith ours internal macros.

Best regards
LV

Ludek Vodicka
Skipper Chief developer www.skipper18.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000