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

后端 未结 2 1299
刺人心
刺人心 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 04:16

    Well, I think that you must first understand the purpose of precompiled headers. In large projects, it can take ages to process all the headers required by a single client extension for example, so some people prefer to distribute the .pch files along with their libraries. In order to generate the .pch files, you use the /Yc compiler flag and the person who wants to consume your library will set the /Yu flag. See here and here for details.

提交回复
热议问题