views:

93

answers:

1

Hi, experts,

I tried to reuse the .pch to speed the build using the following way:

  1. use /Yc on stdafx.cpp to create the .pch files to a folder
  2. exclude stdafx.cpp in the project, and modify the link option

It success in my machine, but failed in another, got the error message: error C2011: '*' : 'struct' type redefinition

So first I want to ask whether the .pch files are machine sensitive? then secondly, the above approaches workable?

Thanks!

+3  A: 

Precompiled headers can be machine specific up to Visual Studio 2008 SP1 (from 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.

MSN
True, but unrelated to error C2011.
MSalters