Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / May 2004

Tip: Looking for answers? Try searching our database.

Viewing statics while debugging

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom Doster - 30 May 2004 22:46 GMT
How can I see the value of a static variable when debugging? Static's don't show up in the variable-window and when I type the name of a static variable in the watch-window the debugger says this the symbol is not defined

I'm in Visual C++ 6.0

Thanks
Tom
Carl Daniel [VC++ MVP] - 30 May 2004 22:54 GMT
> How can I see the value of a static variable when debugging? Static's
> don't show up in the variable-window and when I type the name of a
> static variable in the watch-window the debugger says this the symbol
> is not defined.
>
> I'm in Visual C++ 6.0.

Type the fully qualified name:

struct X
{
   static int i;
};

-->  You need to type X::i in the watch window.

-cd
Tom Doster - 31 May 2004 02:36 GMT
Thanks. How would I reference with the debugger a static variable that is declared and defined in a member function of a class

void theClass::theMemberFunction()

   static int theVariableOfInterest = 5
   . . .
   // do some things including setting theVariableOfInterest  to some new valu
   // Somewhere down here put a breakpoin

I've tried various things, but none worked

BTW: Will this variable be shared across all instances of class 'theClass'

Thanks
To
Carl Daniel [VC++ MVP] - 31 May 2004 03:09 GMT
> Thanks. How would I reference with the debugger a static variable
> that is declared and defined in a member function of a class?

AFIAK, you can't.

> void theClass::theMemberFunction()
> {
[quoted text clipped - 5 lines]
>
> I've tried various things, but none worked.

You could set a breakpoint in the function, determine the address of the
local static, and then add a watch to that address, I suppose.

> BTW: Will this variable be shared across all instances of class
> 'theClass'?

Yes.

-cd

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.