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?
In the UI, you can configure an "External Tool" (from the tools menu). You can make such a tool that invokes the compiler with the current file and the "/P" option and have the compiler output to the screen. For the external tool, configure it to output to the output window.
You compile proc using the same method within C++ project and external build tool. you right click on proC file and if the compiler instruction are set in Custom Build Setup (in MS Visual Studio) it will show you output i.e. C/C++ file
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:
- Command:
C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe
- Arguments:
$(ProjectDir)$(ProjectFileName) /Build "Debug-Preproc|Win32"
- Command:
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].i
for 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.