views:

364

answers:

6

Hello

Go To definition in Visual studio 2005 works only for files that are in my project. It never works for files that are included in external libraries like mfc. When I say Go To Definition for mfc function it always shows me the header file . Is this expected behavior? And also how does this whole thing Go To Definition work? Thanks

A: 

Yes only the interfaces for MFC will be given in header file.Unless it is implemented with Template you will not be able to access the actual definition.The dlls have implementation for those interfaces.

yesraaj
A: 

Well if you think about it logically, as far as visual studio knows the only definition of the MFC object that is available is the definition it sees in the associated MFC header file, so unless you actually have the entire source for MFC it won't be able to look anywhere else.

The way that intellisense/go to definition works is via a file that is created when you compile the application. It stores a mapping between variables/functions and where they are declared (or could potentially be declared, in polymorphic situations), and when you right click to say "go to definition" it references that file.

MBillock
+1  A: 

External libraries are references to their compiled DLLs rather than the source when referencing your own projects.

The idea is that you don't need any more than the interface to external classes, but, if you would like to see the internals of DLLs you can use a tool such as Reflector.

Seth
As the OP is talking about headers and MFC he's obviiously not using a managed language. That means Reflector is not of much use for him.
Frank Bollack
+2  A: 

I'd make the small investment required in Visual Assist. Besides all the great features it offers, it has the Alt+G command which works way better than the Visual Studio go to definition :)

Flawe
But it doesn't change the behavior he's experiencing here. Function definitions compiled into static libraries are often simply not available. And since you had to give a plug, I'll counter it with WT completely ignored Visual Studio UI design guidelines for Visual Assist resulting in a wholly unusable extension. Even given it for free I can't use it.
280Z28
I agree there, it does have a rather strange ui, but I don't understand why you can't use it?
Flawe
+1  A: 

For the MFC source files (at least the Feature Pack ones) I learned to find out what folder are they in (usually at C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc) and add that folder to the Find in Files dialog.

It's not as direct as Go to Definition, and you may have to browse among the find results, but it works...

Note: I second @flippy's answer of Visual Assist, it's really great.

djeidot
A: 

Yes this is the expected behavior. Only the declarations (header files) of the MFC code are available on your box and hence that is the only location that it can take you to.

What are you expecting it to show?

JaredPar