VC++6.0常見問題之fatal error C1083解決方案


                                             積累技術之路上的點點滴滴

C1083: Cannot open precompiled header file: 'Debug/<Project-Name>.pch': No such file or directory

This error results from a missing file - the compiled version of StdAfx.cpp. Visual C++ does a poor job of keeping track of this file and frequently "forgets" how to build it. This problem often occurs after restoring a saved workspace from diskette without the Debug directory. To fix the error select StdAfx.cpp from the workspace file list them choose Compile from the Build menu. If that doesn't work the go to Project -> Settings, select the C/C++ tab, and click the radio button labeled Create Precompiled Headers.

Unexpected end while looking for precompiled header
這時因為該模塊沒有包括預編譯頭文件“stdafx.h”的緣故。
VC用一個stdafx.cpp包含頭文件stdafx.h,然后在stdafx.h里包含大部分系統頭文件,這
樣編譯時VC就通過編譯stdafx.cpp把大部分系統頭文件預編譯進來了,在Debug目錄下有
一個很大的文件*.pch,這里就存儲了預編譯信息。
根據這個原理,如果這個pch損壞了或被刪除了,系統重新編譯時就會抱怨“cannot open
precompiled header file debug/*.pch”。這時怎么解決這個問題呢,打開Project-》
Setting對話框選C++頁,將Category下拉式列表框選中Precompiled Headers,最簡單的
辦法就是選中第一個選項“Not using....",這樣就根本不用預編譯頭也不去尋找pch文件,
就不會出錯了,但是這樣做的后果是每次編譯、連接都化更多的時間。
也可以選第二個選項”Automatic ...",然后在“Through header”力填上stdafx.h,這樣
如果沒有pch文件系統會自動生成一個pch,如果有的話就使用這個pch,這個選項是比較“
智能”的。
第三個選項是強行創建一個pch文件,第四個選項是直接使用pch文件。當然“Through
headers”里都填stdafx.h了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM