Macro Expansion
Overview
You can inspect the code generated by the expansion of a macro in two ways:
inline: DVT replaces the macro call with the generated code in place; the expanded code is guarded by pragmas that allow DVT to collapse the code back to the original
in a separate editor: DVT opens a new editor window that shows the generated code
Triggering
To expand
Place the cursor on a macro call in the editor, right click, select from the pop-up menu Macros and then the desired expand type. Expansion also works for an entire region of code, and all macros in the selection will be expanded. DVT also marks inline macro expansions in the code and collects them in the tasks view to allow easy tracking.
You can choose to expand only the first level (i.e. further macro calls inside the top level macro are not expanded) or all levels. You can quickly collapse a macro expansion by right-clicking on its marker.
Note
You can also expand all macros in the current file by placing the cursor anywhere in the editor and selecting either Expand All Macros Inline, for expansion in the source file, or Expand All Macros, for expansion in a temporary file.
To collapse
Place the cursor on the expansion start pragma, and select Collapse Inline Expansion.
Warning
Do not modify the pragmas generated by DVT because this might break the collapse functionality!
DVT will notify you if the macro expansion in the editor does not match the current macro definitions. This may happen either because the expansion or the macro definitions have been modified since the macro was expanded. A compare window will display the differences between the editor expansion and the expansion with current macro definitions.
Note
You can also collapse all macro expansions in the current file by placing the cursor anywhere in the editor and selecting Collapse All Inline Expansions.
Tips
- Shortcuts
There are some handy keyboard shortcuts you can use for triggering:
Expand one level inline |
Ctrl+Shift+= |
Collapse inline expansion |
Ctrl+Shift+- |
- Selection
Expansion also works for an entire region of code, and all macros in the selection will be expanded.
- Markers
DVT also marks inline macro expansions in the code and collects them in the tasks view to allow easy tracking.
- Quick collapse
You can quickly collapse a macro expansion by right-clicking on its marker.
IMPORTANT NOTE
Warning
Do not modify the pragmas generated by DVT because this might break the collapse functionality!
The pragmas are:
@DVT_EXPAND_MACRO_INLINE_START
@DVT_EXPAND_MACRO_INLINE_ORIGINAL
@DVT_EXPAND_MACRO_INLINE_END