本文介绍了我什么时候想关闭“预编译头"?在视觉工作室?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我想说的是,我阅读了有关预编译头文件的信息,并且我了解这是一种优化,它节省了我在每次编译时都反复编译头文件的时间.

我正在阅读boost的文档,并且在说明中看到它们说:

然后他们解释:

  1. 有人能解释一下我用粗体标记的句子吗?他们正在谈论哪些Visual Studio特定更改? (以下是我正在阅读的文档的链接: http://www.boost.org/doc/libs/1_55_0/more/getting_started/windows.html#pch )
  2. 为什么以及何时要关闭预编译的标头?
  3. 预编译的标头选项中的创建"和使用"之间有什么区别.
解决方案

最初是评论,但我也可能会发表.注意:这是特定于VC ++的:

  1. 大胆的句子是他们说样本不遵循统一使用此首领用于pch生成模型的口头禅的方式. IOW,他们的示例不是PCH友好的,但是如果配置正确,您仍然可以在项目中使用带有增强功能的pch.

  2. 出于各种原因,您将其关闭.一些源模块,特别是来自第三方的模块,并不遵循PCH模型,即一开始就包含"pch-through-header".他们的样本就是这样的代码(因此建议关闭它们以获取样本).有时,源文件仅对此文件需要不同的预处理器配置,而并非项目中的所有文件都需要.禁用这些文件的PCH的另一个原因.

  3. 您通常使用 a 源/标头对生成一个";预编译的头文件映像.该头文件通常包括:

    1. 项目使用的任何系统标准库头文件
    2. 第三方SDK标头
    3. 关于未在您的项目中积极开发的所有其他内容.

标记为 Create 的单个源文件通常包含一行代码:#include "YourHeaderFile.h",其中YourHeaderFile.h是您用上面列表中的内容填充的标题.通过头文件YourHeaderFile.h将其标记为创建"将告诉VC,它是在编译其他源文件时通过该头文件重建PCH所需的文件.所有其他源文件都标记为使用(PCH已关闭的文件除外),并且应包含与它们相同的#include "TheHeaderFile.h"./p>

简而言之(难以置信),<boost>告诉您它们的样本未按照上述说明进行设置,因此,在构建它们时应关闭PCH .

First of all i want to say that I read about precompiled headers and I understand that this is an optimization that saves me the time of compiling headers over and over on every built.

I'm reading the documentation of boost and I see that in the instructions they say:

And then they explain it:

  1. Can some explain me the sentence I marked in bold? which visual studio specific changes they are talking about ? (Here is the link to the documentation I'm reading: http://www.boost.org/doc/libs/1_55_0/more/getting_started/windows.html#pch)
  2. Why and when I would want to turn off the precompiled headers?
  3. what is the difference between "Create" and "Use" in the precompiled header options.
解决方案

Originally a comment, but I may as well post it. Note: this is specific to VC++:

  1. The bold sentence is their way of saying the samples don't follow the mantra of a unified use-this-lead-in-header-for-pch-generation model. IOW, their samples aren't PCH-friendly, but you can still use pch with boost in your projects if properly configured.

  2. You would turn them off for a variety of reasons. Some source modules, particularly ones from 3rd-parties, don't follow the PCH model of including "the" pch-through-header at their outset. Their samples are such code (and thus the advise to turn them off for their samples). Sometimes source files require different preprocessor configurations only for this files and not all files int he project; another reason to disable PCH for those files.

  3. You typically use a source/header pair to generate "the One"; the precompiled header image. This header file typically includes:

    1. Any system standard lib headers used by your project
    2. 3rd-party SDK headers
    3. Just about everything else that is NOT in active development for your project.

The single source file tagged as Create typically includes one line of code : #include "YourHeaderFile.h", where YourHeaderFile.h is the header you filled with stuff from the list above. Tagging it as "Create" through header YourHeaderFile.h tells VC it is the file needed for rebuilding the PCH through that header when compiling other source files. All other source files are tagged as Use (except the ones where PCH is turned off) and should include, as their first line of code, the same #include "TheHeaderFile.h".

In short (hard to believe), <boost> is telling you their samples aren't setup like described above, and as such you should turn PCH off when building them.

这篇关于我什么时候想关闭“预编译头"?在视觉工作室?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 09:06