“预处理当前文件” Visual Studio 的插件? (C++)

发布于 2024-08-26 05:58:35 字数 144 浏览 4 评论 0原文

我意识到Visual Studio有“/P”选项来生成预处理文件,但它非常不方便。我正在寻找一个插件,允许您右键单击文件并选择“查看预处理” - 或任何类似的解决方案,基本上可以预处理当前打开的文件(使用当前配置中的适当选项)并向我展示输出,没有额外的麻烦。这样的事存在吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

黎夕旧梦 2024-09-02 05:58:35

使用“外部工具”菜单没有真正优雅的方法来执行此操作,但这里有一个可行的解决方案:

  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,从而在文本编辑器中打开文件。

它不像右键单击文件并选择“预处理”那么干净或方便,但我认为这是您在编写扩展时所得到的最好的结果。

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.

烟酒忠诚 2024-09-02 05:58:35

在 UI 中,您可以配置“外部工具”(从工具菜单中)。您可以制作这样一个工具,使用当前文件和“/P”选项调用编译器,并将编译器输出到屏幕上。对于外部工具,将其配置为输出到输出窗口。

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.

怪异←思 2024-09-02 05:58:35

Visual Macros 扩展器:- Visual Studio 的插件,它显示扩展宏甚至格式化结果。

Visual Macros Expander: - addin for visual studio, it shows expanded macroses and even formats results.

染年凉城似染瑾 2024-09-02 05:58:35

您可以在 C++ 项目和外部构建工具中使用相同的方法编译 proc。右键单击 proC 文件,如果在自定义构建设置(在 MS Visual Studio 中)中设置了编译器指令,它将显示输出,即 C/C++ 文件

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文