Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Go To Definition/Declaration

Status
Not open for further replies.

beffnooy

Programmer
Aug 20, 2007
3
US
Visual Studio .NET 2003, Visual C++:

When I hover my cursor over a variable name, the ToolTip that appears correctly identifies the variable's type. If I right-click on the variable name and select "Go To Definition" or "Go To Declaration", I get an MsgBox telling me, "The symbol 'pRoot' is not defined."

I used to get this problem from time to time in VC++ 6.0, but with that product, I could enable "Build Browse Information", rebuild, and I would be good to go. This does not work in VC++ .NET 2003.

Am I misunderstanding the term "browse"? The on-line docs for BSCMAKE indicates that supplying the /FR flag will include information for local variables. I have looked at the .sbr file before BSCMAKE is invoked, and the variable name is present. It is also present in the .bsc file (when I look at it in a HEX editor -- if I open it in VStudio, it gets loaded into the Object Browser).

Anyone have any advice for me?

Thanks,
rfj
 
You don't really need to add browse info on 2003. It should do it automatically. The problem is that if it is a conversion, the .ncb file can get a bit screwed. Come out of Visual Studio, delete the .ncb file, start up visual studio, reload the solution and try again.

Another problem is headers in classes. Something like
Code:
class Squirrel
{
   ...
#include "nested.h"
   ...
};
Anything defined in nested.h will not be picked up by the class browser or intellisense even though it will compile correctly.
 
That didn't solve my problem.

I didn't really think it would, since I had written a small program from scratch to see if there was something that was covered up by the larger solution's complexity and size, and it showed the same behavior.

Thanks,
rfj
 
Can you post that small program? Perhaps we can see a way to fix it or at least learn what causes the problem.
 
Here is the source code. I had intended to include all of the project, but I couldn't find an option to attach a zip file. If needed, I can paste the .sln and .vcproj into a post.

The project also includes stdafx.cpp and stdafx.h, but those were the standard files that VC++ gives you -- I didn't change anything in them.

Please let me know if there is anything else I can supply that will help with discovering a solution.

Thanks,
rfj
Code:
// BrowseTest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

void    func1(void);
void    func2(void);

int     global = 0;

int _tmain(int argc, _TCHAR* argv[])
{
    int     localMain = 1;

    global++;
    if (global == localMain)
    {
        func1();
    }

	return 0;
}

void    func1(void)
{
    int     localFunc1 = 2;

    global++;
    if (global == localFunc1)
    {
        func2();
    }

    return;
}

void    func2(void)
{
    int     localFunc2 = 3;

    global++;
    if (global == localFunc2)
    {
        return;
    }
}
 
So the problem is with the local variables, right? Maybe the Go To Definition and Go To Declaration don't work on local variables.

I tried your example code and some code of my own and local variables never worked.

Perhaps it's time to rethink the size of your functions if you can't find the declaration of a local variable in it. ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top