Using / YC and / MP together in a Visual Studio 10 project

I am trying to circumvent the / YC and / MP constraint, which are mutually exclusive. I would like to use precompiled headers and multi-process compilation.

My answer so far has been to create 2 projects instead of 1. The first is a pch generation library consisting only of stdafx.h and stdafx.cpp. It generates a pch file with / yc installed on stdafx.cpp

This library successfully creates the pch! As an additional note, the pch library project also has / YU, pointing to its stdafx.h and / Fp, linking to the pch output file.

My second project is my main executable. It has / MP, but does not have / YC for any file and does not contain stdafx.h or stdafx.cpp. Instead, I install the / YU project in stdafx.h of the pch library and / Fp in pch generated by the pch library. Then I installed the pch library as a dependency on the exe project. I also installed / FI in the exe project to force stdafx.h from the pch library to be included in every compilation unit.

My problem is that although the pch library generates a pch file, and the exe project seems to correctly reference the generated pch file, as soon as the exe project starts building (after some pre-build steps not related to pch), it removes pch generated by the pch library. I guess this is because he thinks with / Fp that the project will generate this file even if / YC is not.

Am I doing something wrong here? I skipped a step. Is there a way to prevent the exe project from deleting my pch file before it is created?

Any help would be greatly appreciated!

+4
source share
1 answer

Try the following: Does Visual C ++ verify the need to regenerate my pch if I use / Yc

Basically you set / Yc for stdafx.cpp and / Yu + / MP for all other * .cpp files.

To set flags separately for each file, right-click the cpp file in Solution Explorer and select Properties.

+6
source

All Articles