watch variable??

This is a discussion on watch variable?? within the C++ Programming forums, part of the General Programming Boards category; i have used VS2005 to do programing ,but i find a problem while i'was looking into a variable(named hr ) ...

  1. #1
    Registered User
    Join Date
    Oct 2008
    Location
    china
    Posts
    16

    watch variable??

    i have used VS2005 to do programing ,but i find a problem while i'was looking into a variable(named hr ) with debugging.

    such as the codes:

    Code:
    HRESULT DXUTChangeDevice( DXUTDeviceSettings* pNewDeviceSettings, IDirect3DDevice9* pd3dDeviceFromApp, bool bForceRecreate )
    {
        HRESULT hr;//problem,can't watch variable
        DXUTDeviceSettings* pOldDeviceSettings = GetDXUTStat().GetCurrentDeviceSettings();
    
     .
     . 
     .
     .
     .
     .
     .
     .
     .
     .
    my question is why can't vs 2005 debuger watch the variable "hr" ,seem to me that think any complile optimization
    Last edited by haochao; 10-11-2008 at 03:09 AM.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,012
    Are you debugging in release mode? If so, then it's a common problem and the only solution is to look at the asm and try to track the register the value is stored in (or just print some debug messages).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Oct 2008
    Location
    china
    Posts
    16
    you mean i'm should be debug mode,watching variable in asm ,is not my purpose!

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    23,012
    If you debug in debug mode, you'll be able to see the values of each and every variable. Optimization sometimes removes variables.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #5
    Registered User
    Join Date
    Oct 2008
    Location
    china
    Posts
    16
    yes, thanks for your reply but can't solve this problem yet

  6. #6
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Well, are you debugging in debug mode or not?

    Where are you trying to watch the variable from? It's a variable local to that function, so I imagine that watching it might not work too well if that function hasn't been called yet, for example.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  7. #7
    Registered User
    Join Date
    Oct 2008
    Location
    china
    Posts
    16
    no,i'm watch variable inside that function, not out of scope.

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Well then the variable is probably being optimised out of existence. Disable as many optimisations as you can and see what happens.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  9. #9
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Third time's a charm:
    Are you debugging in debug mode or release mode?
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about printing a variable???
    By Hoser83 in forum C++ Programming
    Replies: 2
    Last Post: 03-31-2006, 01:57 PM
  2. How accurate is the following...
    By emeyer in forum C Programming
    Replies: 22
    Last Post: 12-07-2005, 12:07 PM
  3. static class variable vs. global variable
    By nadamson6 in forum C++ Programming
    Replies: 18
    Last Post: 09-30-2005, 04:31 PM
  4. Replies: 8
    Last Post: 04-22-2002, 11:02 PM
  5. Variable Allocation in a simple operating system
    By awkeller in forum C Programming
    Replies: 1
    Last Post: 12-08-2001, 02:26 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21