can't see values of variables in VC++ 2008 with add watch or quick watch while debugging

star90
star90 used Ask the Experts™
on
Hi,
I am calling a function from main() and inside this function I have defined local variables.
I am using the debugging mode. (step by step pressing F10)
I can't see the value of the variables, not by quick watch, not by add watch.

e.g.
 int line_number;
line_number=get_value();
cout<<line_number;

I see in the watch window:
CXX017 : ERROR : symbol "line_number" not found.

any suggestions?
Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
masheikSoftware Engineer

Commented:

select the variable want to watch and right click in popup menu u see a opiton addto watch click that..
can you try disabling the optimize code option in the project and file properties or try add  namespace into the file?

Commented:
Sorry, if it is a kind of a terrible advise - please be sure that you see Debug Win32 configuration.
If it is, you can check the project settings - it should be _DEBUG in the Preprocessor Definitions.
evilrixSenior Software Engineer (Avast)

Commented:
You don't show the code so this is really an advisory rather than an answer... if the function is inline you may not be able to view the symbols it contains in the debugger. Under some circumstances (but not all oddly enough) the symbols are not available.

As I said before, this is just something for you to be aware of and is not intended as an answer to your problem (I'd suggest the real problem has already been identified by pgnatyuk).
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

Author

Commented:
I can see Debug and Win32 in the main screen of the debugger (I am using Vista 64 bit)
In the Project-> C/C++ -> Preprocessor  ->Preprocessor definitions  : WIN32,NDEBUG,_CONSOLE
there is no option for choosing  _DEBUG
Is there a different setting for vista 64?

I copied the cpp files to another dir and it seems to be working OK. (I can see the values of variables inside functions while debugging)
I am still checking it with bigger input files.
How can I compare the project settings between the 2 folders?
evilrixSenior Software Engineer (Avast)

Commented:
>> there is no option for choosing  _DEBUG
That doesn't control the symbols. the important thing is the code isn't being optimized and symbols are being generated (I'm at home without VC so I can't check what those are, but rest assured it is not controlled by preprocesser settings).

>> How can I compare the project settings between the 2 folders?
http://winmerge.org/

Commented:
you can replace just manually NDEBUG for _DEBUG. Probably it will be not enough. If the problem will still exists you will have to check other project settings beginning from the optimization as evilrix said - there is a page in project settings where you will find the optimization parameter - it should be "Disable". Please clear/re-build solution before the test.
evilrixSenior Software Engineer (Avast)

Commented:
>> I can see Debug and Win32 in the main screen of the debugger (I am using Vista 64 bit)
>> In the Project-> C/C++ -> Preprocessor  ->Preprocessor definitions  : WIN32,NDEBUG,_CONSOLE

Actually, I just look at that again and I realized something is wrong. NDEBUG should only be defined in a release build so if you are saying it's defined in debug then I'd say your project settings are probably mixed up some how. I doubt very much that just changing NDEBUG to _DEBUG will fix all your issues.

Commented:
If all we proposed here will not help, create on another location a similar project and manually copy the project settings from the debug configuration into your main project.

Author

Commented:
Thanks
I do see that in the new project has the _DEBUG value for the preprocessor.

I will copy the cpp files to the new project and work there until I am able to understand what is the problem in the old one.

Is it OK to work with Debug Win32 setting when I am using vista 64 bit?
How can I know that there are no more setting problems in my project?
Thanks!



Commented:
I thought you don't need to copy all source files to the new project. Just open 2 Visual Studio's, open the debug configuration, and item after item verify all settings in the DEBUG configuration.
I also use vista. It works. There are specific settings, but, I think, no it does not matter.
It is nice if you can create new projects and copy all source file, restore all resources, etc. But I don't know how big is your project. So we can try to fix the existing project. But you decide.
 
 
Senior Software Engineer (Avast)
Commented:
>> Is it OK to work with Debug Win32 setting when I am using vista 64 bit?
Yes, it's built 32 bit binaries, which will still run on Win64 (all be it in 32 bit mode)

>> How can I know that there are no more setting problems in my project?
Well, NDEBUG should NEVER exist in a debug built so I'd question how it got there. Without having access to the project I could only guess on other issues. I would create a new project and migrate the files over to it... keep the old one for reference just in case.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial