1.unexpected end of file while looking for precompiled header directive
原因不清楚,一般工程不會出現此問題,這次出現此問題主要是我用了於士其寫的關於免裝dxshow所寫的類CameraDS所導致(解決此問題是一個非常痛苦的過程),解決方案是 工程->設定->所有配置->c/c++->先行編譯標頭檔->自動使用預補償頁首
2.在Visual C++ 中以錯誤的順序連結CRT 庫和MFC 庫時出現LNK2005 錯誤
上網搜到微軟的解答,具體網址:http://support.microsoft.com/kb/148652/zh-cn
癥狀
當 C 運行時 (CRT) 庫和 Microsoft 基礎類 (MFC) 庫的連結順序有誤時,可能會出現以下 LNK2005 錯誤之一:
nafxcwd.lib(afxmem.obj) :error LNK2005:
"void * __cdecl operator new(unsigned int)"(??2@YAPAXI@Z) already
defined in LIBCMTD.lib(new.obj)
nafxcwd.lib(afxmem.obj) :error LNK2005:
"void __cdecl operator delete(void *)"(??3@YAXPAX@Z) already defined
in LIBCMTD.lib(dbgnew.obj)
nafxcwd.lib(afxmem.obj) :error LNK2005:
"void * __cdecl operator new(unsigned int,int,char const *,int)"
(??2@YAPAXIHPBDH@Z) already defined in LIBCMTD.lib(dbgnew.obj)
mfcs40d.lib(dllmodul.obj):error LNK2005:_DllMain@12 already defined in
MSVCRTD.LIB (dllmain.obj)
mfcs42d.lib(dllmodul.obj):error LNK2005:_DllMain@12 already defined in
msvcrtd.lib(dllmain.obj)
回到頂端
原因
CRT 庫對 new、delete 和 DllMain 函數使用弱外部連結。MFC 庫也包含 new、delete 和 DllMain 函數。這些函數要求先連結 MFC 庫,然後再連結 CRT 庫。
回到頂端
解決方案
該問題有兩種解決方案。第一種方法是強制連結器按照正確的順序連結庫。第二種方法是由您親自尋找導致問題的模組並糾正它。
注意:下列步驟基於 Visual C++ 6.0 進行。
回到頂端
解決方案一:強制連結器按照正確的順序連結庫
1.
在“項目”菜單上,單擊“設定”。
2.
在“項目設定”對話方塊的“以下項目的設定”視圖中,單擊以選中出現連結錯誤的項目配置。
3.
在“連結”選項卡上,單擊以選中“類別”組合框中的“輸入”。
4.
在“忽略庫”框中,插入庫名(例如,Nafxcwd.lib;Libcmtd.lib)。
注意:等效的連結器命令列是:/NOD:<library name>。
5.
在“對象/庫模組”框中,插入庫名。必須確保這些庫按順序列出,而且是行中的前兩個庫(例如,Nafxcwd.lib 和 Libcmtd.lib)。
要在 Visual C++ .NET 中設定該選項,請閱讀“設定 Visual C++ 項目屬性”線上說明主題。
3.error C2833: ''operator DEBUG_NEW'' is not a recognized operator or type
也是上網找到答案的,這是vc6編譯的bug,用2005則沒此問題,原因及解決方案如下:
Symptom:
When compiling an application (in which a header file has just been changed) the Microsoft Visual C++ compiler generates the compiler error:
... /include/crtdbg.h (536) : error C2833: ''operator DEBUG_NEW'' is not a recognized operator or type
followed by in excess of 20 errors.
This is well-known annoying bug in VC++ IDE, this happens when precompiled header file is corrupted. Rebuild All helps in this case
Cause
Normally the compiler error C2833 means that the specified symbol is not recognised and this indicates a simple programming error.
This specific error, in ‘crtdbg.h’ involving ‘operator DEBUG_NEW’, is a compiler bug. This bug has been observed in Visual Studio 5 and Visual Studio 6 (up to and including service pack 5).
Possible Remedies:
These remedies deal with the compiler bug only.
Try recompiling. This sometimes cures the problem.
If recompiling does not cure the problem then ‘clean’ the affected project and rebuild. This has always been observed to cure the problem.
Anders Musikka has contributed the following tip: It is not necessary to do a full clean of the project and rebuild. You can just delete the xxx.pch file in the debug/release directory and recompile the failed .cpp file(s).
Whilst it is in no way conclusive, this bug may be related to the project precompiler header settings. I have noticed that it only seems to affect projects where the precompiled headers is set to ‘automatic use of precompiled headers’.
文章出處:http://www.diybl.com/course/3_program/vc/vc_js/2008426/111565.html