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
 namespace or typedef problem
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cwdrat
Junior Member

19 Posts

Posted - Oct 22 2008 :  2:05:57 PM  Show Profile  Reply with Quote
VA_X.dll file version 10.4.1649.0 built 2008.09.09
Licensed to:
VA X: <snip> (10-user license) Support ends 2009.09.26
DevEnv.exe version 9.0.21022.8
msenv.dll version 9.0.21022.8
Font: Courier New 13(Pixels)
Comctl32.dll version 6.0.2900.5512
Windows XP 5.1 Build 2600 Service Pack 3
2 processors

Platform: Win32
Stable Includes:
C:\\Program Files\\Microsoft DirectX SDK (August 2007)\\Include;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\include;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\include;
C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include;
C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\include;

Other Includes:

Stable Source Directories:
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\src\\mfc;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\src\\mfcm;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\atlmfc\\src\\atl;
C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\crt\\src;


namespace ns
{

template< typename T > 
struct Foo
{
  T *operator ->() const;
};

struct Bar
{
  void method();
};

typedef Foo< Bar > FooBar;

}

namespace ns2
{

template< typename T > 
struct Foo
{
  T *operator ->() const;
};

struct Bar
{
  void method2();
};

typedef Foo< Bar > FooBar;

}

int
main( int argc, char **argv )
{
  ns::Foo< ns::Bar > fb;
  fb->method(); // suggestion is correct
  
  ns::FooBar fb2;
  fb2->method(); // suggestion is correct

  ns2::Foo< ns2::Bar > fbn2;
  fbn2->method2(); // suggestion is correct

  ns2::FooBar fbn22;
  fbn22->| // no suggestion
}


I've been trying to reproduce a slightly different failure and came across this in the process. The problem in my production code is similar - I have typdef'ed template classes with the same name in different namespaces, in different headers located in different file directories. My .cpp only #includes files from one of these directories (explicitly ala #include <path2/header.h>), and my "problem" variable is declared with the appropriate namespace prefixed. Unfortunately, VAX suggests members from the other class from the wrong header from the wrong namespace.

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Oct 24 2008 :  3:36:43 PM  Show Profile  Reply with Quote
Are you able to reproduce this problem in a new win32 test project?

I started a new win32 project, put your 2 namespace into 2 different headers in 2 different paths, put your example function into the main cpp file, and then I got "method2" after fbn22->

Edited by - accord on Oct 24 2008 3:37:34 PM
Go to Top of Page

cwdrat
Junior Member

19 Posts

Posted - Oct 24 2008 :  4:14:56 PM  Show Profile  Reply with Quote
quote:
Originally posted by accord

Are you able to reproduce this problem in a new win32 test project?

I started a new win32 project, put your 2 namespace into 2 different headers in 2 different paths, put your example function into the main cpp file, and then I got "method2" after fbn22->



My posted test code was created in a single .cpp file in a blank test project. I hadn't gotten as far as separating the code into multiple files before encountering the above problem. Let me try referencing my production libraries in the test program and see what I can learn from that.
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Oct 24 2008 :  4:29:19 PM  Show Profile  Reply with Quote
First I tried to paste your code into a single cpp file, and everything was fine. After that, I separated your source followed your problem description to see if this helps to reproduce the problem here.

So it may mean that the answer is in your settings or in your parsed directories.

Edited by - accord on Oct 24 2008 4:35:22 PM
Go to Top of Page

cwdrat
Junior Member

19 Posts

Posted - Oct 24 2008 :  5:32:07 PM  Show Profile  Reply with Quote
Okay, I was wrong about the namespaces - both versions of the library use the same namespace name. I should explain that this is simply two versions of the same library that exist in our source tree to maintain compatability with our programs that haven't yet been ported to the new version.

When I used my test project I got the right members listed corresponding to which header I #included the first time I tried it. Specifically, I used the new library header and got new members, then old library header and got old members. When I switched back to the new library headers VAX always lists the members from the class in the old library. It's like it's gotten "stuck" on the old header. I forced VAX to reparse the file - didn't fix it. Then I had it rebuild the symbol database, and that made it work again until I #included the old header again, at which point it got stuck on the old class again. I even get the old members when I comment out all #include statements.
Go to Top of Page

cwdrat
Junior Member

19 Posts

Posted - Oct 24 2008 :  5:35:19 PM  Show Profile  Reply with Quote
So I tried something else.

In header1.h:
#ifndef HEADER1_H
#define HEADER1_H

namespace NS
{

struct Foo
{
  void Method1();
};

}

#endif

In header2.h:
#ifndef HEADER2_H
#define HEADER2_H

namespace NS
{

struct Foo
{
  void Method2();
};

}

#endif

And in my .cpp file:
#include "header1.h"

int
main( int argc, char **argv )
{
  NS::Foo foo;
  foo.| // suggests both method1() and method2()
}
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Oct 26 2008 :  6:32:13 PM  Show Profile  Reply with Quote
*ah* Now, it makes sense!

This is because Visual Assist parses as much as it can, for example pre-parsing a lot of system header, parsing all files in your project, AND parses the included files in the currently opened file also. Visual Assist offer suggestions based on files ever parsed and NOT by your includes in the actual file.

This is by design and it can be useful: you can write code and you will get suggestions before you put the necessary includes, so you can do it later.

Isn't it possible to separate your equally named classes into different namespaces?

Edited by - accord on Oct 26 2008 6:50:42 PM
Go to Top of Page

cwdrat
Junior Member

19 Posts

Posted - Oct 28 2008 :  2:27:48 PM  Show Profile  Reply with Quote
quote:
Originally posted by accord

*ah* Now, it makes sense!

This is because Visual Assist parses as much as it can, for example pre-parsing a lot of system header, parsing all files in your project, AND parses the included files in the currently opened file also. Visual Assist offer suggestions based on files ever parsed and NOT by your includes in the actual file.


Unfortunately, in my production code the suggestions are not the union of the members of both versions of the class (that would be much easier to live with). It exclusively lists members from the old class and none from the new one.
Go to Top of Page

cwdrat
Junior Member

19 Posts

Posted - Oct 28 2008 :  6:02:42 PM  Show Profile  Reply with Quote
Don't know if it matters, but tooltips that popup when I hover over member accesses that are underlined in red (because they are members introduced in the new lib) correctly display the signature of the function and its overloads.

I can also access the refactor menu, and after performing a Find All References I seem to be getting the correct behavior in this source file now.

Edited by - cwdrat on Oct 28 2008 6:06:15 PM
Go to Top of Page

cwdrat
Junior Member

19 Posts

Posted - Oct 28 2008 :  6:08:18 PM  Show Profile  Reply with Quote
quote:
Originally posted by accord

...AND parses the included files in the currently opened file also. Visual Assist offer suggestions based on files ever parsed and NOT by your includes in the actual file.


Does it parse commented #includes too?
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Oct 29 2008 :  4:51:04 PM  Show Profile  Reply with Quote
>Does it parse commented #includes too?
No, it doesn't.

>after performing a Find All References I seem to be getting the
>correct behavior in this source file now.
Next time if you run into a refresh problems like this, can you please try to close, and then reopen the file to see if this helps?

I tried your example, but it worked for me. When I included the first header after rebuild databases, it listed "Member1" for me. After that I commented out the first header and then included the second header and I got both of "Member1" and "Member2".

Are your libraries added to the project's additional include directories?

Project properties -> C/C++ -> General -> Additional Include Directories

or are your libraries added to the global include path here:

IDE tools menu -> Options -> Projects and Solutions -> VC++ Directories -> Show directories for = Include files
Go to Top of Page

cwdrat
Junior Member

19 Posts

Posted - Oct 30 2008 :  2:04:10 PM  Show Profile  Reply with Quote
quote:
Originally posted by accord

Are your libraries added to the project's additional include directories?


The project has an additional include directory that is the root of our source-controlled libraries. It's something like "../../lib", since the applications are in the same tree (we use relative paths wherever possible because of source branching).

Both versions of the library giving me trouble are found in subfolders of this lib folder.
Go to Top of Page

cwdrat
Junior Member

19 Posts

Posted - Oct 30 2008 :  2:41:34 PM  Show Profile  Reply with Quote
Okay, I'm sorry this is so hard for me reproduce. I did some more digging, and yet another assumption I was making is incorrect. The classes baked into the typedef do not have the same name.

header1.h:
#ifndef HEADER1_H
#define HEADER1_H

namespace NS
{
template< typename T >
struct Bar
{
  T *operator ->() const;
};

struct IFoo
{
  void method1();
};

typedef Bar< IFoo > BarFoo;
}

#endif

header2.h:
#ifndef HEADER2_H
#define HEADER2_H

namespace NS
{
template< typename T >
struct Bar
{
  T *operator ->() const;
};

struct TFoo
{
  void method2();
};

typedef Bar< TFoo > BarFoo;
}

#endif

sandbox.cpp:
#include "header1.h"

int
main( int argc, char **argv )
{
  NS::BarFoo barfoo;
  barfoo->|
}

I hope this finally makes some kind of sense and demonstrates the problem (try alternating between #including header1.h and header2.h). I can't wait until we just retire the old library and delete it from the source tree...
Go to Top of Page

accord
Whole Tomato Software

United Kingdom
3287 Posts

Posted - Nov 03 2008 :  4:42:54 PM  Show Profile  Reply with Quote
Great work! I was able to reproduce the problem using your example:

case=20712

For now, you can turn on

VA Options -> Advanced -> Listboxes -> Get content from default Intellisense

as a workaround if you did not turn off default intellisense, for example by renaming feacp.dll.
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