VC编译常见错误

上传人:l**** 文档编号:45257415 上传时间:2018-06-15 格式:DOC 页数:10 大小:63.50KB
返回 下载 相关 举报
VC编译常见错误_第1页
第1页 / 共10页
VC编译常见错误_第2页
第2页 / 共10页
VC编译常见错误_第3页
第3页 / 共10页
VC编译常见错误_第4页
第4页 / 共10页
VC编译常见错误_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《VC编译常见错误》由会员分享,可在线阅读,更多相关《VC编译常见错误(10页珍藏版)》请在金锄头文库上搜索。

1、VC 编译常见错误- -1、Fatal Error C1010unexpected end of file while looking for precompiled header directive这一般是由于使用了参数/Yu“stdafx.h“,意思是在每个文件中都应该使用#include 来包含这个头文件。一般改正,就是在每个。CPP 文件中包含这个文件就可以。2、LNK2001 on _beginthreadex and _endthreadex这是一个非常常见的链接错误。原因是由于在 VC3。0 以后所有的 MFC 类都是线程安全的,在 MFC 类库中使用了 Thread Local

2、 Storage (TLS)提供预处理的数据。因此如果程序中包含了“stfafx.h“头文件或者使用了,MFC 类库中的类就会使用 MSVCRTx0.DLL 来进行链接。改正方法如下:On Visual C 2.x, 5.0, and 6.0: Select the Project menu, and then continue Steps 2 through 5 below.On Visual C 4.x: Select the Build menu.Select the Settings. option.Select the C/C+ tab.Select Code Generation

3、on the Category list box.Finally, make a selection other than Single-Threaded on the Use Run Time Library list box.如果使用了“Multithreaded using DLL“方式还要求在预处理符号中加上_AFXDLL 符号.还在 LIBC。LIB 是 C Runtime 的静态链接库。MSVCRTx0.DLL 是 C Runtime 的动态链接库。如果程序中包含了任何 MFC 代码,或者编译使用了/MT 选项,都要求使用多线程库。为什么在程序中包含了“StdAfx.h“文件也会出

4、现这个连接错误呢?是由于在“StdAfx.h“中使用了 MFC 类,并且重载了 new 等操作符,如果在程序中使用了 NEW 等就会出现链接错误。1、Fatal Error C1010unexpected end of file while looking for precompiled header directive这一般是由于使用了参数/Yu“stdafx.h“,意思是在每个文件中都应该使用#include 来包含这个头文件。一般改正,就是在每个。CPP 文件中包含这个文件就可以。2、LNK2001 on _beginthreadex and _endthreadex这是一个非常常见的链

5、接错误。原因是由于在 VC3。0 以后所有的 MFC 类都是线程安全的,在 MFC 类库中使用了 Thread Local Storage (TLS)提供预处理的数据。因此如果程序中包含了“stfafx.h“头文件或者使用了,MFC 类库中的类就会使用 MSVCRTx0.DLL 来进行链接。改正方法如下:On Visual C 2.x, 5.0, and 6.0: Select the Project menu, and then continue Steps 2 through 5 below.On Visual C 4.x: Select the Build menu.Select the

6、 Settings. option.Select the C/C+ tab.Select Code Generation on the Category list box.Finally, make a selection other than Single-Threaded on the Use Run Time Library list box.如果使用了“Multithreaded using DLL“方式还要求在预处理符号中加上_AFXDLL 符号.还在 LIBC。LIB 是 C Runtime 的静态链接库。MSVCRTx0.DLL 是 C Runtime 的动态链接库。如果程序中包

7、含了任何 MFC 代码,或者编译使用了/MT 选项,都要求使用多线程库。为什么在程序中包含了“StdAfx.h“文件也会出现这个连接错误呢?是由于在“StdAfx.h“中使用了 MFC 类,并且重载了 new 等操作符,如果在程序中使用了 NEW 等就会出现链接错误。http:/ C+ Error MessagesVisual C+ Error MessagesThis page contains a listing of “difficult to diagnose“ error messages and possible fixes. I havent taught a programmi

8、ng class that uses Visual C+ in several years so this list is probably out of date by now. It was valid for Microsoft Visual C+ version 6.0 service pack 3.C1001: INTERNAL COMPILER ERROR (compiler file msc1.cpp, line 1786) Please choose the Technical Support command on the Visual C+ Help menu, or ope

9、n the Technical Support help file for more informationThis error results from leaving off the parentheses immediately following the function name in a function header. To correct the error simply add () to the end of the function name.C1010: unexpected end of file while looking for precompiled heade

10、r directiveIf your project is an MFC AppWizard created project then this error results from not #including StdAfx.h as the first i nclude statement (before any other i ncludes, data declarations, or executable program code).C1083: Cannot open precompiled header file: Debug/.pch: No such file or dire

11、ctoryThis 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

12、select StdAfx.cpp from the workspace file list them choose Compile from the Build menu. If that doesnt work the go to Project - Settings, select the C/C+ tab, and click the radio button labeled Create Precompiled Headers.C2001: newline in constantThis error is usually caused by a string or character

13、 constant that is missing its closing or “ symbol.C2065: : undeclared identifierIf this error occurs in one of your member functions then it is generally the result of forgetting the class scope operator in front of the function name in your .cpp file.C2143: syntax error : missing ; before PCH creat

14、ion pointCheck each of the i nclude files to ensure that the closing brace of each class declaration is followed by a semicolon.C2143: syntax error : missing ; before *If this error is followed by two C2501 errors then the problem is an undeclared class name within a pointer declaration.For example,

15、 the declaration:CClass *pObject;will generate the above error message followed by a C2501 error message for CClass and another C2501 message for pObject. The problem is that the compiler isnt recognizing CClass as a valid class/type name. To correct the problem add a i nclude of the file containing

16、 the declaration of CClass (e.g., i nclude CClass.h)C2447: missing function header (old-style formal list?)This error usually results from a missing or use of a ; instead of a following the parameter list of a function header.C2511: : overloaded member function not found in This error results from a mismatch in the parameter list of a member function declaration (.h file) a

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 行业资料 > 其它行业文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号