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.