Pre-compiled header file:
The most common application scenario is the stdafx. h file, which contains common header files, such as Windows. H, cstdio, string, and other. cpp files to include the stdafx. h header files. Although stdafx. H is included by multiple. cpp files, stdafx. H is compiled only once. This accelerates compilation.
Stdafx. cpp is used to generate pre-compiled files. There is only one line of code in stdafx. cpp # include "stdafx. H". Compiling stdafx. cpp will generate a. PCH file. This. PCH file is used when other. cpp files are compiled.
It seems that there are still advanced application scenarios, which are not yet known.
Usage of pre-compiled headers:
1. Create the pre-compiled header file stdafx. H. This header file contains the header file you want to include. Be sure not to include your own header file, but only the system header file, which will not change.
2. Create stdafx. cpp, which contains stdafx. h.
3. Let the compiler know that the stdafx. cpp file is used to create a. PCH file. Right-click the stdafx. cpp file and choose --> properties --> All configurations --> C/C ++ --> pre-compilation header --> select: Create Pre-compilation header (/YC)
4. Let the compiler know which. cpp files need to use the. PCH file. Before using. the. add # include "stdafx. H ", and then in. right-click the CPP file --> properties --> All configurations --> C/C ++ --> pre-compilation header --> select: Use the pre-compilation header (/YU)
5. Compile stdafx. cpp separately to generate the. PCH file. If you accidentally delete the. PCH file, compile the stdafx. cpp file separately.
Note:
1. Not all. cpp files must contain stdafx. H. whether to use the pre-compiled header can be modified in the configuration item.
2. if. if the CPP file uses a pre-compiled header file. the beginning of the CPP file contains stdafx. otherwise, the # include "stdafx. # include code before H. Warning c4627: "# include" lua_notifyicon.h ": skipped when searching for pre-compiled Headers
Refer:
Http://38288890.blog.163.com/blog/static/19612845320081164495863/
Http://www.cnblogs.com/magic-cube/archive/2011/12/06/2278568.html