can i use multiple PCH files in 1 project?
Asked Answered
N

2

7

I want to use the PCH file to speed up the build, so i store the PCH file in a separate folder and reuse it when build the project later.

but I have some #import *.dll in my stdafx.h. so if something changed in the *.dll, the PCH file need be recreated.

my question is whether I can use multiple PCH files in 1 project, so that i can put the import *.dll to another PCH and only recreate this one if something changed in *.dll.

thanks in advance :)

Norm answered 30/3, 2010 at 2:21 Comment(0)
A
3

No, you can only include one pch file per cl.exe invocation.

It's a bummer but that's the way it is.

Alban answered 1/4, 2010 at 0:42 Comment(0)
B
2

Yes you can set per cpp file which pch to use.

Just go to the .cpp file's properties and then go to the pre-compiled header tab. (Configuration Properties -> C/C++ -> Precompiled Headers) You can specify which pre-compiled header to use there.

You should only put things that don't change in your pre compiled headers though.

Bingham answered 30/3, 2010 at 2:28 Comment(2)
Thanks for your kindly reply. But want I want to do is 1 .cpp file use multiple pch files. The reason is that I have a big stdafx.h, and I want to divide it to some small ones, so that in case something changed, only the small pch need be re created. Thanks!Norm
@fresky: No but you can simply point that 1 cpp file to some third pch that contains the contents of both of them. The third one would only simply include the other 2.Bingham

© 2022 - 2024 — McMap. All rights reserved.