I realize that Visual Studio has the “/P” option to generate preprocessed files, but it’s extremely inconvenient. I’m looking for an addin that allows you to right-click on a file and select “view preprocessed” – or any similar solution that would basically preprocess the currently-open file (with the appropriate options from the current configuration) and show me the output, with no extra hassle. Does such a thing exist?
I realize that Visual Studio has the /P option to generate preprocessed files, but
Share
There’s no really elegant way of doing this using the External Tools menu, but here’s a solution that will work:
Create a new configuration for your project. Call it something like “Debug-Preproc”. In this configuration, set the /P switch for the compiler. (Preprocess, no compilation.)
Go to the External Tools setup menu. Create a new item called “Preprocess Project”. Set the options to:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe$(ProjectDir)$(ProjectFileName) /Build "Debug-Preproc|Win32"You can now use the “Preprocess Project” option on your menu to run the preprocessor against all source files in the currently selected project. It will generate
[filename].ifor each one, which you can open in a text editor.If you want, you can create an additional step to open the file in a text editor by adding a new external tool to your editor to open
$(ItemFileName).i.It’s not nearly as clean or convenient as being able to right-click a file and pick “preprocess”, but I think it’s the best you’ll get short of writing an extension.