Search code examples
c++debuggingvisual-studio-2008macros

How to debug macros efficiently in VS?


I've got a pretty complicated macro inside my (unmanaged) C++ code. Is there any way to expand macros in VS debugger? Or maybe there is another way to debug macros there?

F.e. I'd like to place a breakpoint inside it.

(Yes, I know macros are bad.)


Solution

  • Go to either project or source file properties by right-clicking and going to Properties. Under Configuration Properties->C/C++->Preprocessor, set Generate Preprocessed File to either with or without line numbers, whichever you prefer.

    This will show what your macro expands to in context. If you need to debug it on live compiled code, just cut and paste that, and put it in place of your macro while debugging.