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
 Technical Support
 Anonymous namespace issue.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

johnny5
New Member

4 Posts

Posted - Jul 17 2011 :  3:10:50 PM  Show Profile  Reply with Quote
IDE: Visual Studio 2010
VAX: 10.6.1850.0

Find all references and renaming do not work correctly in anonymous namespaces of different implementation files when they both contain declarations of the same name.

Say you have two implementation files:

test.cpp:

namespace
{
  int x = 5;
  void func() { }
}

test2.cpp:

namespace
{
  int x = 0;
  void func() { ++x; }
}

void func()
{ }


If you were to find references of x in test.cpp you will also get both references of x from test2.cpp.
The same behavior occurs when searching for func.

If you were to find references of x in test2.cpp you will also get the reference of x from test.cpp.
The same behavior occurs when searching for func. Also, it is finding the global func which it should not be finding.

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Jul 18 2011 :  11:01:54 AM  Show Profile  Reply with Quote
I am seeing the same effect here. Thank you for the clear description.

case=58805

There is a reason behind this though. Visual Assist looks only for the scope, in this case both "func"s are in the "same" anonymous scope. But you are right, these are two unrelated files which don't includes each other so they are different compilation units. The thing is that Visual Assist pre-parses everything, every file when you load the project, and considers everything as a potential source that you might want to work with. That said, you can start typing symbol names from headers that are not even included and Visual Assist will help you. (Later, you can use the "Add Include" refactoring to add them.)

So if you have symbols with the same name, but in a different namespace or in a different class, etc. if will be differentiated. But two symbols in the same (e.g. global) scope are considered the same scope by VA.

problem 2: I have put in a bug report for this:

case 58807 Anonymus and global namespace are treated as it would be the same scope

Edited by - accord on Jul 18 2011 11:02:27 AM
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