“预处理当前文件”;用于Visual Studio的插件? (C ++) [英] "preprocess current file" addin for Visual Studio? (C++ )

查看:117
本文介绍了“预处理当前文件”;用于Visual Studio的插件? (C ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Visual Studio具有 / P选项来生成预处理文件,但这非常不便。我正在寻找一个允许您右键单击文件并选择查看预处理的加载项-或基本上可以对当前打开的文件进行预处理(使用当前配置中的适当选项)并向我显示的任何类似解决方案输出,没有多余的麻烦。这样的事情存在吗?

解决方案

使用外部工具菜单没有真正优雅的方法,但是这里有一个解决方案将会起作用:


  1. 为您的项目创建新的配置。称其为 Debug-Preproc。在此配置中,为编译器设置/ P开关。 (预处理,无需编译。)


  2. 转到外部工具设置菜单。创建一个名为预处理项目的新项目。将选项设置为:




    • 命令: C:\Program Files\Microsoft Visual Studio 9.0\Common7 \IDE\devenv.exe

    • 参数: $(ProjectDir)$(ProjectFileName)/ Build Debug-Preproc | Win32


您现在可以使用预处理菜单上的项目选项,以对当前所选项目中的所有源文件运行预处理器。它将为每个文件生成 [filename] .i ,您可以在文本编辑器中打开该文件。



如果您可以根据需要,通过在编辑器中添加新的外部工具以打开 $(ItemFileName).i ,来在文本编辑器中打开文件的步骤。

它不像右键单击文件并选择预处理那样干净或方便,但是我认为最好不要编写扩展名


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?

解决方案

There's no really elegant way of doing this using the External Tools menu, but here's a solution that will work:

  1. 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.)

  2. 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"

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.

这篇关于“预处理当前文件”;用于Visual Studio的插件? (C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆