山自高兮水自深,当尘雾消散,唯事实流传。

2008-06-17

VC6.0的INTERNAL COMPILER ERROR错误

同样的程序运行在两台机器上,一台可编译,在另一台机器上的VC6.0上会报如下错误:

fatal error C1001: INTERNAL COMPILER ERROR 
(compiler file 'msc1.cpp', line 1786) 

重新配置编译环境、重装VC未果,不得其解,GG一把,大都说是M$的Bug,既然是Bug就不必在上面纠缠了,解决这个问题的三种方法贴在下面,我是用第3种方法解决的:
造成这种问题的原因是编译器分配的内存超过了限制。 
解决的办法有三种: 
1.给编译器增大内存限制。在project(工程)->setting(设置)->c/c++的project option(工程选项)中,添加/Zm#nn选项,#nn是一个数字,取值最大为2000。默认为100。但是这种方法好像没有什么用处。 
2.将模板类头文件从stdafx.h中移出; 
3.不使用预编译头文件。project->setting->c/c++,选择所有的.cpp文件,都使用“不使用预编译头文件“的选项。缺点是编译的时候很慢。 

更专业点的英文解释:
When template classes or template class header files are included in a precompiled header file, the compiler may generate the following error for files that use the precompiled header: 

  fatal error C1001: INTERNAL COMPILER ERROR
  (compiler file 'msc1.cpp', line 1786)

  -or-

  fatal error C1001: INTERNAL COMPILER ERROR
  (compiler file 'msc1.cpp', line 1188)
   
This error occurs only on machines with the Windows 95 or Windows 98 operating system. 

CAUSE
The compiler exceeds the allocated memory limit. 

RESOLUTION
Use one of the following three suggested workarounds: 
Use compiler switch /Zm#nn to increase the compiler's heap memory allocation limit. The default value of #nn is 100 and the maximum value is 2000. Manually add this switch in Developer Studio: under the Project menu, click Setting, the click C/C++, then Project Options. Usually, a value of 1000 works. 

NOTE: You may need to increase the system virtual memory to accommodate the increased #nn for /Zm. 工程| 设置 | “C/C++” | “工程选项"


-or- 
Remove the template class header files from the precompiled header file. 

-or- 
Use "Automatic use of precompiled headers" (/YX switch), or, "Not using precompiled header."


STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. 

没有评论: