The pre-compiled header file cannot be opened after I have vomited blood for one afternoon.

Source: Internet
Author: User

Environment: vs2008

Language: C ++

In the afternoon, a terrible problem occurred. One of my MFC-based dialog box programs cannot be compiled because of the precompiled header file stdafx. h. Because the program needs to pre-compile the header file as a whole. Therefore, all CPP files in the project include # include stdafx. h.

My own files are stored in a self-built folder under the project folder. For example, the project name is dynamicpathplan. My files samplepredictmodel. h and samplepredictmodel. cpp are placed in the "C:/current actual robot code/dynamicpathplan_selfloc/dynamicpathplan/selfloc" folder. The stdafx. h automatically generated by MFC is placed under the project folder. At the same time, there are several self-written class files under the selfloc folder. In other classes, CPP files also have # include stdafx. H, and there is no error. This file samplepredictmodel is unique. in CPP, the following error occurs: "Fatal error c1083: The file including stdafx cannot be opened. H ": no such file or directory" (I don't know why it reported an error. No other files in the same directory reported an error, of course, if you try to right-click these normal files in the same directory "# include stdafx. H "to open stdafx. h ).

This problem can be avoided if pre-compiled headers are not set in the project properties, but stdafx in all other files must be removed only because of this file. H is really not cost-effective, and stdafx is still required in the dialog box file. h. Therefore, the Engineering Department cannot use the pre-compiled header. I tried to change the include statement to # include ../stdafx. h VC and reported that stdafx. h was not added. Failed. I have searched N for more information on the Internet. In solution manager, you can set whether to use the pre-compiled header for each file. Therefore, the project is set to use the pre-compilation header, and samplepredictmodel. cpp is set separately to not use the pre-compilation header. Delete # include ../stdafx. h. So .... The whole world is quiet .... Compiled. Conclusion 1. The pre-compiled header settings in the project properties are equivalent to the same settings for all files in the project. However, we modify the settings of the file by ourselves, so that only a single file does not use the pre-compilation header. Original, crazy typing.

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.