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++ / October 2004

Tip: Looking for answers? Try searching our database.

Structs and pointers don't display in watch window???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter Steele - 08 Oct 2004 15:55 GMT
Say I have a managed C++ app with some code that looks something like this:

void MyMethod()
{
   struct Point { int x, y; };

   Point* p = new Point;

   p.x = 1;
   p.y = 2;
...
}

During a debugging session, if I create a watch for the variable p, the
watch window does not display its contents. It says it is an invalid
pointer; Further more, if I create a watch for p->x or p->y, it says the
variable does not exist. If I change my code as follows:

struct Point { int x, y; };
...
void MyMethod()
{
   Point* p = new Point;

   p.x = 1;
   p.y = 2;
...
}

then the Watch window correctly displays the value of p as a expandable
structure with a + sign that lets you see x and y as individual variables.

I also had something as simple as this:

{
    int* pi = new int;
    ...
}

and the watch window displayed this value as invalid.

What's going on here anyway? I've experienced a lot of different cases where
the watch window just won't display the values of pointers and simple
structs, whereas in other cases it has no problems. Any suggestions would be
appreciated.
Tomas Restrepo \(MVP\) - 09 Oct 2004 04:01 GMT
Peter,

> Say I have a managed C++ app with some code that looks something like this:
>
[quoted text clipped - 41 lines]
> structs, whereas in other cases it has no problems. Any suggestions would be
> appreciated.

I commented on this a while back on my weblog [1]. Perhaps it might help you
understand a bit what's going on...

[1] http://www.winterdom.com/weblog/archives/000067.html

Signature

Tomas Restrepo
tomasr@mvps.org

Peter Steele - 11 Oct 2004 16:38 GMT
Thanks very much for this info. I suspected it had something to do with
managed/unmanaged code. The pointers in this weblog on the problem will
definitely help.

Peter

> Peter,
>
[quoted text clipped - 53 lines]
>
> [1] http://www.winterdom.com/weblog/archives/000067.html

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.