Pre-compiled header file stdafx. h

Source: Internet
Author: User

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


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.