I am attempting to debug some C code using the visual studio debugger. I seems my choices are to view the source code or view the the disassembly. But what I would really like to view is the source code with all the macro's expended. Is that also possible?
Open up a source file from your manage project in Visual Studio and set a breakpoint on a line. Start debugging in Visual Studio by pressing F5. In Excel, open up your worksheet and start debugging your VBA code using Excel's debugger.
To enable the Disassembly window, under Tools > Options > Debugging, select Enable address-level debugging. To open the Disassembly window during debugging, select Windows > Disassembly or press Alt+8.
To open Disassembly View while debugging, right click your source code and select Open Disassembly View. In the Disassembly View, the yellow hollow marker represents the current instruction.
In addition to source files, macros can be defined on the compilation command line using the -D name = value syntax. For macros defined in such a way, gdb displays the location of their definition as line zero of the source file submitted to the compiler.
In Visual C++ the best you can have is a preprocessed file (C++ ->Preprocessor->Generate preprocessed file). This will give you a huge file of C++ code with all macros expanded. Still macro expansions will be single lines - no line breaks.
This is one of the reasons why macros are very problematic to use for complicated code and should be avoided unless absolutely necessary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With