What is the difference between “Create Precompiled Header” (/Yc) and “Use Precompiled Header” (/Yu) in Visual Studio?

后端 未结 2 1293
刺人心
刺人心 2020-12-31 03:38

I read the documentation in MSDN, but in the end I didn\'t get a clear idea what is the practical difference between them, exactly. Both seem to require stdafx.h to be added

2条回答
  •  暖寄归人
    2020-12-31 03:57

    Short summary of how to use PCH files in Visual Studio:

    • All cpp files in the project have to include stdafx.h (you can change this to something else if you wish)
    • Select project in Solution Explorer and in Properties -> C++ -> Precompiled Headers set 'Create/Use precompiled headers' to 'Use'. Hit Apply
    • While the Property Pages are still shown select stdafx.cpp in solution explorer and set the value to 'Create'

提交回复
热议问题