From Baidu ~
There is no function library in stdafx. h, but some environment parameters are defined so that the compiled program can run in a 32-bit operating system environment.
The include files for Windows and MFC are very large. Even if there is a fast processing program, it takes quite a long time to compile the program. Since each. cpp file contains the same include file, it is silly to process these files repeatedly for each. cpp file.
To avoid this waste, Appwizard works with the VisualC ++ compiler as follows:
◎ Appwizard creates the stdafx. h file, which contains all the mfcinclude files required by the current project file. This file can change with the selected options.
◎ Appwizard, then stdafx. cpp is created. This file is usually the same.
◎ Then Appwizard creates the project file, so that the first compiled file is stdafx. cpp.
◎ When Visual C ++ compiles the stdafx. cpp file, it stores the result in a file named stdafx. PCH. (The extension PCH indicates the precompiled header file .)
◎ When Visual C ++ compiles each subsequent. cpp file, it reads and uses the. PCH file it just generated. VisualC ++ does not analyze windowsinclude files any longer, unless you have edited stdafx. cpp or stdafx. h.
This technology is very sophisticated. Don't you think so? (Also, Microsoft is not the first company to adopt this technology, Borland is .) In this process, you must follow the following rules:
◎ Any. cpp file you write must first contain stdafx. h.
◎ If you have a majority of. cpp files in the project file that require. H files, add them to stdafx. H (back) and pre-compile stdafx. cpp.
◎ Because the. PCH file has a lot of symbolic information, it is the largest file in your project file.
If your disk space is limited, you want to delete the. PCH file from the project file you have never used. They are not required when the program is executed, and they are automatically re-established as the project file is re-established.
What is the use of the stdafx. h and targetver. h header files in Visual Studio 2010?