Error C1853: "debug\consoleapplication1.pch" Precompiled header file comes from an earlier version of the compiler, or the precompiled header is C + + and uses it in C (or vice versa)
Related information:
Http://blog.sina.com.cn/s/blog_674cc1fd0100jirq.html
If the call is unsuccessful as above, remove the precompiled. C File
Right-click the. c file, properties, tap left precompiled header, right precompiled header option choose not to use precompiled header
For the reasons why you should remove the precompiled header, refer to http://blog.csdn.net/shellching/article/details/5260590
When a Visual C + + project has the precompiled header (precompiled header) feature enabled, you may receive a C1853 compiler error if the project has both a. C and. cpp source files mixed: Fatal error C1853: ' pjtname.pch ' Precompiled header file is from a previous version of the compiler, or the precompiled header is C + + and you are using I T from C (or vice versa) (Fatal error C1853: "filename.pch" The precompiled header file comes from an earlier version of the compiler, or the precompiled header is C + + and uses it in C (or vice versa).)
This error occurs because when the. cpp and. c files are mixed in the project, the compiler takes a different approach to compiling them (mainly because the function declaration is handled differently) and therefore cannot share a precompiled header file. In VC + +, the default precompiled header file is for C + + (StdAfx.h and Stdafx.cpp), and of course you can create a precompiled header for C. Interestingly, in the old version of VC + +, this error hint is very misleading: fatal error C1853: ' xxx.pch ' is not a precompiled header file created with this compiler. It often makes people feel confused. It should be said that in the new version of this hint is improved. However, on the Internet search, the problem is often recommended to the entire project to cancel the precompiled header settings, which is obviously not a good solution. For a larger project, using precompiled headers can greatly reduce the overall compilation time. Therefore, it is a better solution to keep the precompiled header settings. Search MSDN for different scenarios that can have different solutions:
I solved it with Method 1.
Scenario 1: Applies to the vast majority of files that are. cpp or most files are. C cases. In this case, it is more balanced to set a small number of different class files to not use precompiled headers, by right-clicking in FileView for the. C (or. cpp) file that you want to cancel the precompiled header for vc++6.0, select Settings, and on the right of the popup dialog box, select Category is precompiled headers, then set option to not using ... ; (for VS2005, in the Solution Explorer, right-click on the corresponding file point and select Properties, under the precompiled Headers key, set the not using ... Can. If you need to set up multiple files, you can hold down the Ctrl key and then select the files and set thePS: Explain the following click on the item click Properties and then select C + + precompiled header to create a header file without using a precompiled header file ( Solution Explorer - Right-click the C or CPP file you want to exclude--pop-up properties menu-expand C + +-precompiled Header - Create/Use Precompiled header -select Not applicable precompiled header
Scenario 2: The affected files are more, then set them all to prohibit precompiled header words will still make the overall project compile speed greatly reduced, not worth the candle. Consider creating a dedicated precompiled header for this set of files. In the very early version of VC + + (1.5 and previous versions) is supported in a single project to establish a precompiled header for. C and. cpp, but only a separate precompiled header is supported in later versions. In this case, we can build a new static library project in workspace (or solution), and add all the. c files independently to the project and compile them separately so that you can target the. C in the static link library. The file is created with a precompiled header. But to some extent, the code that needs to be isolated is logically part of the same module, so it is easy to maintain. However, from the design point of view, this requirement is generally satisfied, otherwise you should consider the overall design of the project: P finally do not forget to set the original project Dependencies (dependency) for the independent out of this static library project.
VS in C + + file call C function, fatal error C1853 precompiled header file from previous version of compiler, or precompiled header is C + + and uses it in C (or vice versa)