Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Feature Requests
 Problem with Boost foreach

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
xxluda Posted - Feb 19 2009 : 08:23:18 AM
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
4   L A T E S T    R E P L I E S    (Newest First)
xxluda Posted - Feb 28 2009 : 04:21:50 AM
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
accord Posted - Feb 27 2009 : 3:53:57 PM
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.
xxluda Posted - Feb 27 2009 : 11:07:10 AM
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
accord Posted - Feb 22 2009 : 1:07:53 PM
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.

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