Visualize Macro Expansion for C++ - C++ Team Blog (original) (raw)

We are excited to announce the availability of Visualize Macro Expansion in Visual Studio 17.7 Preview. This feature lets you visualize the step-by-step expansion of macros. To begin utilizing this feature, ensure that you update to the latest version of Visual Studio Preview.

Visualize Macro Expansion

Visual Studio has introduced an enhanced Macro Expansion feature. This feature brings significant benefits, enabling you to comprehend and review complex multi-level macro expansions in a step-by-step manner. When you hover over a macro, you can access Quick Info, which now includes the Visualize Expansion link in addition to the Copy and Expand Inline options. The Visual Expansion will enable you to visualize the preprocessor passes of the expansion.

Image of Visualize Expansion.

Image of Visualize Expansion.

The Visual Expansion link opens a new window that initially displays the first step of macro expansion. By utilizing the arrows next to the expansion step numbers, you can easily navigate through the subsequent steps of the expansion. This feature proves especially valuable in scenarios involving nested macros with lengthy expansions. In cases where nested macros have long expansions, this feature will help to precisely identify the actions taking place at each step, facilitating a deeper understanding of the macro’s behavior. Ultimately, this feature greatly enhances the efficiency of your debugging efforts, enabling you to pinpoint and resolve issues more effectively.

Gif for visualizing macro expansion process.

Send us your feedback!

Download the latest version of Visual Studio Preview, and try out Visualize Macro Expansion. We would love to hear your thoughts, so please share your feedback in the comments below, on Developer Community, or reach out to us on Twitter (@VisualC) or via email at visualcpp@microsoft.com. Your input is highly appreciated!