Global variable problem in Visual Studio 2010
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Global variable problem in Visual Studio 2010

  1. #1
    Join Date
    Feb 2008
    Posts
    53

    Global variable problem in Visual Studio 2010

    I know globals are generally a bad idea, I just use them for debugging purposes on occasion.

    I have a global variable that is clearly (I checked this multiple times, in multiple ways) not being accessed by any other part of the program. But the value of the variable is being modified somehow, from time to time.

    I'm trying to list possible reasons for why this could be happening. My best guess right now is memory corruption. In particular, perhaps writing past the end of an array.

    What other possibilities should I consider?

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,604

    Re: Global variable problem in Visual Studio 2010

    1. What is the type of this "global variable"?
    2. You chose a wrong Forum for your question: this Forum is for:
    Share bugs and fixes for source code on this site. Also use this to share bugs/fixes in the various class libraries etc. of use to VC++ developers. This is NOT for general programming questions.
    while your problem is a problem in your own code because of some your own bugs.
    Victor Nijegorodov

  3. #3
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,642

    Re: Global variable problem in Visual Studio 2010

    If you think it's memory corruption you can set a data breakpoint to find the reason. Start the debugging session by pressing F10, find the address to that global and then use Debug/New Breakpoint/New Data Brakepoint
    Last edited by S_M_A; August 23rd, 2012 at 12:05 PM.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    http://www.microsoft.com/visualstudio/eng/downloads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center