gpt4 book ai didi

c++ - 预编译头 .pch 文件对机器敏感吗?

转载 作者:行者123 更新时间:2023-11-30 03:11:04 24 4
gpt4 key购买 nike

我尝试通过以下方式重用 .pch 来加速构建:

  1. 在 stdafx.cpp 上使用/Yc 将 .pch 文件创建到文件夹
  2. 排除项目中的stdafx.cpp,并修改链接选项

它在我的机器上成功,但在另一台机器上失败,得到错误信息:error C2011: '***' : 'struct' type redefinition

所以首先我想问一下.pch 文件是否是机器敏感的?那么其次,以上方法可行吗?

谢谢!

最佳答案

预编译 header 可以是特定于 Visual Studio 2008 SP1 的机器(来自 here):

Precompiled header files store the “state” of a compilation up to a certain point, and that state information can be reused in subsequent compiler invocations to significantly increase build throughput. For the past 15 years, our compiler has persisted precompiled headers to disk and reloaded them directly into virtual memory with 99.999% reliability and considerable performance gains. The tradeoff, however, was a degree of fragility in our architecture.

Since the PCH file itself contains internal pointers, it must be loaded at the exact same address in virtual memory where it was created.

关于c++ - 预编译头 .pch 文件对机器敏感吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2597996/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com