PaeneInsula PaeneInsula - 1 year ago 76
C Question

Using #define in VS debugger: any way to hover and see values?

I am writing a C app using VS2010. I have the following #define:

#define wRow Wksp[Session.wkspIndex]->Row

"Row" is an array of structures. So without the defines, it looks like this:


Without the define, I can hover over "value" and see its value.
But when I use the define, like this:


then hovering does nothing at all because (I assume) the debugger is too lazy to do the expansion that I defined.

Is there any way to tell the debugger to expand the
so I can see its value? The same problem appears in the Watch window: I cannot enter
but must use

Answer Source

So basically you are asking how to get the value of this define: hovering in debug mode without define

the same way you would get the value of this variable: hovering in debug mode with define

In Visual Studio 2010, you can not get the value of a macro at debug time the same way you would get the value of a variable. Hovering over a variable actually has the same effect as entering the variable in the watch window, and this watch window is limited in what information it can access because of the format of Visual Studio debug symbols. If you enter the macro vRow in the watch window, you will get:

Error: symbol "vRow" not found

which is why nothing is shown when you hover over vRow.

To debug macro values with Visual Studio, you can set Preprocess to a file to yes in Configuration Properties ->C/C++ ->Preprocessor. Then the next time you compile your program Visual Studio will generate a .i file, which is the output of the preprocessor. By opening this .i file, you can see what is the actual expanded value of your macro, and enter this value in the watch window while you are debugging.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download