Visual Studio see all vars- how?

Started by
13 comments, last by owiley 15 years, 4 months ago
For Visual C++ NET, how can I see ALL my project's variables? I can see them in Class View, but not the local ones (only the globals).
Advertisement
locals only exist within local scope. It wouldn't make sense if you could see them globally. they only exist when the app enters the function and are deconstructed when the app leaves the function (with a few exceptions). Even if the app did let you see them all, it wouldn't really work. For example, consider the following...

void Func1()
{
int someInt = 3;
}

void Func2()
{
int someInt = 3;
}



what should the app report someInt's value as?
Umm, three?
@ Winegums:
I don't need its value, only its being in a complete list of variables. Even displaying its type would not be needed. It'd be a great boon for a newbie user (like me) that has trouble remembering all the variables in a project and their place.
Also, in case someone says it can't be done, Blitz3d already has this facility.
Why would you want to know all the variables in a project?
I only ever care about variables within a scope or namespace. That is a few dozen namespaces to remember then I let intelisense fill in a listing of what is in those namespaces. And if your functions are getting too big that you can't look up and see what variables are in the current scope, then you should be refactoring, or declaring variables closer to the point of usage.

in response to winegums question: 0xBADF00D3 is as good an answer as any if the callstack isn't in either of those functions. There is no reason you'd ever need to know about "someInt" unless you are in the scope of that function. It becomes much more important to remember the name of the function so that you can search for it in the classview.
Besides what information do you get by knowing you have some place with some variable named "someInt"? my code would show that i have 3 variables "i","j","k" used in like 30,000,000 places as loop iterators.
Why would you ever need to do that? I'm assuming you want to avoid name collisions. In that case, this won't be a problem since local variables are out of your scope, as Visual Studio suggests.
As Winegums says, you can't see all your program's variables in the debugger because at any point during execution, most of them won't exist.

If you mean you want to see them in the IDE while writing the code, you can try typing:

::

If you IDE has code-completion (e.g. VS.NET), that should show everything in the global namespace.

Hope that's helpful.
Quote:Original post by asdqwe
For Visual C++ NET, how can I see ALL my project's variables? I can see them in Class View, but not the local ones (only the globals).


the ones in the class view aren't globals. A global is a variable that exists in all contexts of the program.
Quote:Original post by shurcool
Umm, three?


*facepalm*

I really should've read that before posting it...


Quote:

I don't need its value, only its being in a complete list of variables. Even displaying its type would not be needed. It'd be a great boon for a newbie user (like me) that has trouble remembering all the variables in a project and their place.



You don't need to remember all the variables in a project and their place. If you name variables well, comment appropriately and encapsulate where necessary you don't need to know the name of everything at any given moment. I can sort of appreciate the benefit of that if you're new on a project and dropped in the deep end of a giant engine (and spend half an hour just searching the seemingly endless classes and namespaces for some way to gain access to some data), but if you're just programming some app of your own you shouldn't need to know about every variable.

even if you only saw their names, you'd find your list of variables would be worthless with no context ('distance' doesn't mean much outside of a function) (and, as KulSeran said, full of iterators!).
Quote:Original post by shurcool
Umm, three?
[lol]
Quote:Original post by asdqwe
Also, in case someone says it can't be done, Blitz3d already has this facility
It can't be done for variables outside the current scope (The current function or functions further up the call stack). Blitz3d isn't C++, it's BASIC.

This topic is closed to new replies.

Advertisement