Click here to Skip to main content
15,923,845 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to view anonymous namespace variables' values in debugger? Pin
jbarton5-Nov-02 5:04
jbarton5-Nov-02 5:04 
Hi Tim,

While I have not used this with variables in anonymous namespaces, you should be able to setup a watch variable by using the address of the variable.

If you setup a breakpoint at a place that uses the variable, you can open the Disassembly window and find the address of the variable. I tried a sample program which did "cout << anon << endl;", and the disassembly showed:

mov eax,['anonymous namespace'::anon (00476dc0)]

The 00476dc0 is the address of the anon variable for my program. When you run this, it most likely will be a different address.

Once you have the address of the variable, you can setup a watch for it as follows:

* (int *) 0x476dc0

Substitute the address that you get for the 0x476dc0.

This tells the debugger to treat the address as a pointer to int, and then dereferences it. If you want, you can use:

(int *) 0x476dc0

You then get a plus sign which you need to expand to get to the value. For a single value, this isn't useful, but if you have an array, it can be very useful. For instance, if you had the following:

namespace
{
int array[5] = {5,4,3,2,1};
}

Once you find the address of the array in the debugger, you can display the array in a watch window as follows:

((int *) 0x476dc0),5

Again, replace address with the one found in the debugger. This will put a + next to the expression which will expand to 5 elements when clicked.

Best regards,
John

GeneralRe: How to view anonymous namespace variables' values in debugger? Pin
Tim Finer5-Nov-02 7:08
Tim Finer5-Nov-02 7:08 
AnswerRe: How to view anonymous namespace variables' values in debugger? Pin
dshatilov15-Sep-16 0:29
dshatilov15-Sep-16 0:29 
GeneralRe: How to view anonymous namespace variables' values in debugger? Pin
Richard Deeming15-Sep-16 7:10
mveRichard Deeming15-Sep-16 7:10 
GeneralRe: How to view anonymous namespace variables' values in debugger? Pin
dshatilov15-Sep-16 7:56
dshatilov15-Sep-16 7:56 
GeneralPlease Help!! Pin
Autunmsky4-Nov-02 11:38
Autunmsky4-Nov-02 11:38 
GeneralRe: Please Help!! Pin
Christian Graus4-Nov-02 11:50
protectorChristian Graus4-Nov-02 11:50 
GeneralRe: Please Help!! Pin
Gary Kirkham4-Nov-02 11:48
Gary Kirkham4-Nov-02 11:48 
GeneralRe: Please Help!! Pin
Autunmsky4-Nov-02 11:55
Autunmsky4-Nov-02 11:55 
GeneralRe: Please Help!! Pin
Christian Graus4-Nov-02 12:22
protectorChristian Graus4-Nov-02 12:22 
GeneralRe: Please Help!! Pin
Chris Losinger4-Nov-02 12:23
professionalChris Losinger4-Nov-02 12:23 
GeneralRe: Please Help!! Pin
Christian Graus4-Nov-02 12:33
protectorChristian Graus4-Nov-02 12:33 
GeneralRe: Please Help!! Pin
Chris Losinger4-Nov-02 15:01
professionalChris Losinger4-Nov-02 15:01 
GeneralRe: Please Help!! Pin
Christian Graus4-Nov-02 15:17
protectorChristian Graus4-Nov-02 15:17 
GeneralRe: Please Help!! Pin
Chris Losinger4-Nov-02 17:29
professionalChris Losinger4-Nov-02 17:29 
GeneralRe: Please Help!! Pin
Autunmsky4-Nov-02 12:57
Autunmsky4-Nov-02 12:57 
GeneralRe: Please Help!! Pin
Christian Graus4-Nov-02 13:12
protectorChristian Graus4-Nov-02 13:12 
GeneralRe: Please Help!! Pin
Autunmsky4-Nov-02 14:29
Autunmsky4-Nov-02 14:29 
GeneralHelp with Dialog Toolbars Pin
Steven M Hunt4-Nov-02 10:33
Steven M Hunt4-Nov-02 10:33 
GeneralRe: Help with Dialog Toolbars Pin
dabs4-Nov-02 10:50
dabs4-Nov-02 10:50 
GeneralCMenu question. Pin
Anonymous4-Nov-02 10:11
Anonymous4-Nov-02 10:11 
QuestionHow do i at runtime, draw a bitmap in my application? Pin
Anonymous4-Nov-02 9:45
Anonymous4-Nov-02 9:45 
AnswerRe: How do i at runtime, draw a bitmap in my application? Pin
Christian Graus4-Nov-02 9:56
protectorChristian Graus4-Nov-02 9:56 
Generalyes Pin
Anonymous4-Nov-02 10:31
Anonymous4-Nov-02 10:31 
GeneralRe: yes Pin
Christian Graus4-Nov-02 11:06
protectorChristian Graus4-Nov-02 11:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.