预编译头文件和 Visual Studio [英] Precompiled header and Visual Studio

查看:48
本文介绍了预编译头文件和 Visual Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法设置 Visual Studio 解决方案参数,以便它只创建预编译头而不构建整个解决方案.具体来说,它是一个庞大的 C++ 解决方案,本身就有许多项目.

Is there a way to set Visual Studio solution parameters so it just create precompiled headers without building whole solution. Specifically, it is a huge c++ solution with many projects in itself.

谢谢.

推荐答案

这里是 一篇文章 描述了好处以及如何设置它.如果您有较大的项目,那么几次点击和额外的磁盘空间绝对值得.

Here's an article describing the benefits and how to set it up. If you have larger projects, it is definitely worth the few clicks and the extra disk space.

文章说需要将stdafx.h添加到所有源和头文件中;这是不正确的.添加到源代码就足够了 - 确保它是第一行,因为它之前的所有内容都将被忽略.

The article says you need to add stdafx.h to all sources and headers; it's not correct. It's sufficient to add to sources - make sure it's the first line though as everything before it will be ignored.

这篇文章没有提到它,但是你会从不包含 stdafx.h 的来源中得到错误.您可以选择解决此错误:添加它或从预编译过程中排除源.排除源文件:

The article does not mention it, but you'll be getting errors from sources that do not include the stdafx.h. You have a choice to resolve this error: you either add it, or exclude the source(s) from the precompilation process. To exclude source files:

  • 在解决方案资源管理器中选择源文件;是的,您可以一次选择更多,
  • 右键单击突出显示的源文件,
  • 点击弹出菜单中的属性,
  • 从顶部的组合框中选择所有配置",
  • 在 C-C++ 配置下点击预编译头文件",
  • 在右侧选择不使用预编译头",
  • 点击应用,
  • 点击确定.

从现在开始,只需几秒钟即可享受您的新构建(第一个构建需要更长的时间).

Enjoy your new builds in a few seconds from here on (the first build will take longer).

这篇关于预编译头文件和 Visual Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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