ForeverLearning
ForeverLearning

Reputation: 6685

PCH compiler options for MSVC

I am a bit confused about when to use /Yc (create PCH) as opposed to /Yu (use PCH.) For a project that has never used precompiled headers in the past, naturally, the PCH file will not exist initially. Am I supposed to fire off a initial build with /Yc, have it create the PCH file and then change the setting to /Yu for all subsequent builds?

That can't possibly be it, right?

Upvotes: 2

Views: 449

Answers (1)

Richard Critten
Richard Critten

Reputation: 2145

Try this: Create a header to contain all the headers to pre-compile eg: stdafx.h (this MUST be the 1st include in all .cpp files). File to generate the PCH: stdafx.cpp which only includes stdafx.h and compile this with /Yc. All other .cpp files include stdafx.h at the start and compile with /Yu. MSVC is clever enough to do the /Yc file 1st.

Upvotes: 3

Related Questions