最近在編譯一個VC6.0工程(開發環境:win2000+VS6.0+Sp6),在加入先行編譯頭後出現了下面的編譯錯誤提示:
c:/program files/microsoft visual studio/vc98/include/xlocnum(106) :
fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1794)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.
工程中的每個cpp檔案編譯都沒有問題(除了先行編譯頭對應的cpp檔案),很是奇怪,於是在網上找了一下,找到下面一種解決辦法:
VC6.0的一個編譯錯誤的解決
在window98下使用vc6.0時,如果先行編譯標頭檔(stdafx.h)中包含了模板類的標頭檔,比如atl的標頭檔時,編譯器會報錯:
fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
造成這種問題的原因是編譯器分配的記憶體超過了限制。
解決的辦法有三種:
1.給編譯器增大記憶體限制。在project(工程)->setting(設定)->c/c++的project option(工程選項)中,添加/Zm#nn選項,#nn是一個數字,取值最大為2000。預設為100。但是這種方法好像沒有什麼用處。
2.將模板類標頭檔從stdafx.h中移出;
3.不使用先行編譯標頭檔。project->setting->c/c++,選擇所有的.cpp檔案,都使用“不使用先行編譯標頭檔“的選項。缺點是編譯的時候很慢。
(http://www.ieasy.org/yuzuo/archives/2005_07.html)
還有一個英文的:
I see that while compiling ITEL.CPP it is trying and failing to open
Debug/IODIARY.PCH. I also see that there is no IODIARY.CPP. Exactly how is
IODIARY.PCH supposed to be created?
Turn off precompiled headers for all files in the project, and rebuild. If
the build still fails, then... uh-oh..
Modify the project to use the default STDAFX.CPP/STDAFX.H method of using
PCH. Then, add an empty file STDAFX.H and an empty file STDAFX.CPP to the
project. Then, for each .CPP file, add as the first line #include
"stdafx.h" . Then compile. This should work. If it does not... uh-oh.
In order for pre-compiled headers to work properly each .CPP must have as
its first #include statement the name of the one .H (such as STDAFX.H) that
includes all the "actual" .H's (windows.h, stdio.h, etc.) that should be
included by ALL .CPPs.
That is the important part. You don't usually want EVERYsingle .H that is
included in ANY .CPP in the project to be in STDAFX.H -- you do normally
want windows.h, because it is the big one that can include a lot and is
usually included in every .CPP. Putting just windows.h in stdafx.h (and
removing it from all the .CPPs) can speed up the build tremendously.
http://www.codecomments.com/archive307-2005-3-421145.html
在MSDN中搜尋到這種錯誤相關主題:
*http://lab.msdn.microsoft.com/productfeedback/SearchResults.aspx?text=fatal+error+C1001%3a+INTERNAL+COMPILER+ERROR&stype=1&fields=1&type=0&witId=0&pId=0&category=0&os=0&oslang=0&status=0&msstatus=0&resolution=0&chgdays=&validation=0&votes=&voterating=0&workarounds=False&attachments=False
*http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/c1001.asp
後來把先行編譯去掉後,Build終於通過了運行了,可這也太慢了,鬱悶中……
還不知有沒更好的解決辦法??同樣的工程放在VC++.net2003中卻編譯順利通過,運行正常.!!!!