VC编译常见错误- -
1、Fatal Error C1010 1、Fatal Error C1010 http://www.blog.edu.cn/user2/shuquanying/archives/2006/1327664.shtml Visual C++ Error Messages Visual C++ Error Messages This page contains a listing of "difficult to diagnose" error messages and possible fixes. I haven't taught a programming 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 open the Technical Support help file for more information This 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 header directive If 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/<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. C2001: newline in constant This error is usually caused by a string or character constant that is missing its closing ' or " symbol. C2065: '<data-member name>' : undeclared identifier If 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 creation point' Check each of the #i nclude files to ensure that the closing brace of each class declaration is followed by a semicolon.
If this error is followed by two C2501 errors then the problem is an undeclared class name within a pointer declaration. For example, 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 isn't recognizing CClass as a valid class/type name. To correct the problem add a #i nclude of the file containing 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: '<function-name>' : overloaded member function not found in '<class-name>' This error results from a mismatch in the parameter list of a member function declaration (.h file) and definition (.ccp file). Check the forward declaration of the function in the .h file and its definition in the .cpp file and ensure that the number of parameters and the type of each parameter match exactly. C2512: '<constructor-function-name>' : no appropriate default constructor available This error usually occurs when you implement the constructor function of a derived class and forget to include parameter passing to the base class constructor function. For example assume that CDerived is derived from CBase and that the CBase constructor function requires one parameter (e.g., int A). If you define the CDerived constructor function as: CDerived::CDerived(int A, int B) { ... } the compiler will issue the above error message on the line containing the function header of CDerived::CDerived() because you haven't provided instructions for routing the parameter A to CBase::CBase(). Because you didn't provide instructions the compiler assumes that CBase::CBase() requires no arguments and it complains because no version of CBase::CBase() has been defined that accepts zero arguments. If you intended to provide a version of CBase::CBase() that requires no arguments then the error message indicates that you forgot to declare that function in your base class declaration (e.g., in CBase.h). If CBase::CBase() does require one or more arguments then you must correct the problem by including explicit instructions for passing parameters from the derived class constructor function to the base class constructor function. The correction for the example above is: CDerived::CDerived(int A, int B) : CBase(A) { ... } C2556: '<function-name>' : overloaded functions only differ by return type These errors usually result from a mismatch of function type between a .h and .cpp file. Check the forward declaration of the function in the .h file and its definition in the .cpp file and make the function return type identical in both files. C2601: '<function-name>' : local function definitions are illegal This error results from defining one function inside the body of another function. It usually means that you omitted one or more } symbols in the function just before the function named in the error message. C2653: '<Class-Name>' : is not a class or namespace name This error usually results from not having #i nclude "StdAfx.h" as the first #i nclude statement in your class.cpp file. It can also occur if your class definition is in a .h file and you forget to #i nclude that .h file in another file that refers to the class name. C2661: '<Class-Name>::<Function-Name>' : no overloaded function takes n parameters This error indicates a mismatch between the parameters used in a function call (e.g., from main.cpp) and the declaration of the function. The function call is passing n parameters and there is no function declaration that uses that number of parameters. LNK1104: Cannot open file nafxcwd.lib This error sometimes occurs when a project uses a class from the MFC but the project settings don't explicitly tell the link editor to look in the MFC libraries. Go to Project --> Settings (Build --> Settings in Visual C++ 4.0). On the General tab check the box that says "Use MFC in a Shared DLL". LNK1168: cannot open Debug\<Project-Name>.exe for writing This error occurs when the link editor attempts to write to a .exe file that is currently in use. The .exe file of an executing program is write protected until the program is terminated. Look at the status bar at the bottom of your screen and find the icon representing your executable application. Open the application and exit from it. Then select Build. LNK2001: unresolved external symbol __endthreadex These errors result from using an MFC object or function without telling the link editor to search the MFC libraries. Go to Project --> Settings (Build --> Settings in Visual C++ 4.0). On the General tab check the box that says "Use MFC in a Shared DLL". LNK2001: unresolved external symbol _main Your project doesn't contain a function called main(). The error usually results from forgeting to add main.cpp to the project workspace. <File>.obj : error LNK2001: unresolved external symbol "public: void __thiscall <Class1>::<Function1>(<Type>)" This a generic form of a LNK2001 error where <File>.obj can be any object file in your project and <Class1>::<Function1>(<Type>) can be any function in any class. Substitute the specific <File>, <Class>, <Function>, and <Type> in your message into the instructions below to diagnose and correct the problem. An LNK2001 error means that the link editor is looking for a compiled function and can't find it. The call to the "missing function" is somewhere in <File>.cpp. Unfortunately, double-clicking on the error message won't take you to the point in <File.cpp> where the function is called but you can search for it with Find or Find In Files. The function the link editor can't find is a member of <Class>, its name is <Function1>, and its return type is <Type>. There are two common reasons for a LNK2001 error: LNK2005: <some-long-string-of-mostly-garbage> already defined in <name>.lib(<name>.obj) This error usually results from including a source code file multiple times. If you recognize any of the names in the message then it probably results from multiple inclusion of one of your own header files. Check to be sure that you've used #ifndef/#define/#endif properly your header files. If you don't recognize the name then it's probably multiple inclusion of a system file (e.g., afxwin.h). Make sure that you haven't explicitly included something in main.cpp that is already included in one of your own header files. Also check that you haven't #i ncluded a .cpp file where you should have #i ncluded a .h file. http://yinqing.blog.hexun.com/5383739_d.html 作 者:happyparrot 出处:[url]http://community.csdn.net/Expert/topic/4258/4258967.xml?temp=.1825373[/url] 1. Linking... Q: VC++默认的工程设置是单线程的,而你使用了多线程,所以要修改设置。选择菜单“Project|settings”,选择C/C++标签,在CODE GENERATION分类中选择除SINGLE-THREADED的其他选择。 2.fatal error C1010: unexpected end of file while looking for precompiled header directive Q: 3.在编译时产生的下面的代码,那么下面的代码中的括号内的数字代表什么意思,还有error后的数字呢? operator with side-effect Q:括号中的数字是出错的代码行的行号。例如错误中的第1行表示CalWnd.cpp的1092行出现了错误。如果想快速找到这行,可以在错误信息行上双击鼠标,这时VC++会自动打开CalWnd.cpp文件并定位到这行。 4.vc编译的时候可以设置两个版本:debug和release,debug版本在运行的时候点击帮助菜单的about对话框出现如下错误信息: Q: 5. 在win2000上能编译的程序到了win98就不能编译了。 Q:是和编译帮助文件有关,据说如果在Win98下安装了Norton AntiVirtus 2000就会出现这种问题。可以把帮助文件从工程中去掉: 6.在用EnumWindows(EnumWindowsProc,(LPARAM)0);编译时老是出错:cannot convert parameter 1 from 'int (struct HWND__ *,long)' to 'int (__stdcall *)(struct HWND__ *,long)' Q:实际上看一下错误信息就知道,你的EnumWindowsProc大概定义为: 7.编译以WinMain开头的函数出现LNK2001错误 8.编译后出现大量错误信息怎么办 Q:不可能一一为你分析错误,告诉你一些消除错误的原则,你自己来逐一分析,这样你才能学会编程。 编译,因为一个匹配错误可能引发几十个错误,继续查后面的错误意义不大。 http://zhangxiaocai.spaces.live.com/blog/cns!13130e6871dda08f!129.entry VC++常见编译错误信息 2、fatal error C1083: Cannot open include file: 'R…….h': No such file or directory 3、error C2011: 'C……': 'class' type redefinition 4、error C2018: unknown character '0xa3' 5、error C2057: expected constant expression 6、error C2065: 'IDD_MYDIALOG' : undeclared identifier 7、error C2082: redefinition of formal parameter 'bReset' 8、error C2143: syntax error: missing ':' before '{' 9、error C2146: syntax error : missing ';' before identifier 'dc' 10、error C2196: case value '69' already used 11、error C2509: 'OnTimer' : member function not declared in 'CHelloView' 12、error C2511: 'reset': overloaded member function 'void (int)' not found in 'B' 13、error C2555: 'B::f1': overriding virtual function differs from 'A::f1' only by return type or calling convention 14、error C2660: 'SetTimer' : function does not take 2 parameters 15、warning C4035: 'f……': no return value 16、warning C4553: '= =' : operator has no effect; did you intend '='? 17、warning C4700: local variable 'bReset' used without having been initialized 18、error C4716: 'CMyApp::InitInstance' : must return a value 19、LINK : fatal error LNK1168: cannot open Debug/P1.exe for writing 20、error LNK2001: unresolved external symbol "public: virtual _ _thiscall C……::~C……(void)" ======================================================================================== |
VC常见编译错误
最新推荐文章于 2019-10-22 21:42:07 发布
来源:
http://hi.baidu.com/gtxuq/blog/item/c46d8494ab92c41ad21b70c2.html