




已阅读5页,还剩8页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
VS2010 C+错误处理办法(转载)vs2010中文旗舰版怎么出现创建新项目失败?你可以试试:开始 - 所有程序 - 附件 - 命令提示符(右键点击一管理员身份运行)。打开后,再输入Regsvr32 JScript.dll。错误:1 fatal error C1010: unexpected endof file while looking for precompiled header. Did you forget toadd #includeStdAfx.h to your source?#includeStdAfx.h 你把这个放在头文件里面就行了2vc+编程出现错误error C2447: missing function header (old-styleformal list?)原因:函数后面多了分号;SUNSHINE_APISSN_RETURN SsnWriteProfileString(_in INT nPlugInId, _in_opt LPTSTRlpszGroupName, _in LPTSTR lpszKey, _in LPTSTR lpszValue);3errorC2491: SsnWriteProfileString : definition of dllimport function not allowed错误C2491:“SsnWriteProfileString:dllimport函数的定义不允许的SUNSHINE_API SSN_RETURNSsnWriteProfileString(_in INT nPlugInId, _in_opt LPTSTR lpszGroupName, _inLPTSTR lpszKey, _in LPTSTR lpszValue)查看SUNSHINE_API在 .h文件中的定义#ifdefSSNAPI_EXPORTS#defineSUNSHINE_API_declspec(dllexport)#else#defineSUNSHINE_API_declspec(dllimport)#endif将#ifdef SSNAPI_EXPORTS添加到#include的下面;形如:#include#defineSSNAPI_EXPORTS则解决;4 error C2065: “CString”:未声明的标识符在非mfc下使用CString 会导致上面错误:解决办法:(1)如果你使用VC.net那么:使用MFC:包含cstringt.h;不使用MFC:包含atlstr.h(2)或者 #include 5error C2065: DEBUG_NEW : undeclared identifier?删除.cpp文件中的#ifdef _DEBUG#undef THIS_FILEstatic char THIS_FILE=_FILE_;#define new DEBUG_NEW#endif6 问题:error C2440: initializing : cannot convert from constchar 34 to TCHAR 128错误C2440:“初始化”:不能把字符常量34 TCHAR128原因:编译选项有没有开了UNICODE;做法:在vs2010下设置unicode编译选项,去掉unicode模式,具体设置方法为:项目-属性-配置属性-字符集-未设置project-Properties-ConfigurationProperties-General-Character Set-Not Set/hrh2010/article/details/66812717问题:C1083:Cannot open include file: stdafx.h: No such file or directoryC1083:无法打开包括文件:“stdafx.h中”:没有这样的文件或目录解决:stdafx.h文件和工程的.h文件放在一个位置;8 error C2065: “cout”: 未声明的标识符解决方法:加上#include using namespace std;9错误:error C3872: 0x3000: thischaracter is not allowed in an identifier错误C3872:0X3000“:此字符不允许在标识符0x3000是汉语的空格,也就是全角空格,相当于一个汉字,但你又看不见它。你知道的,像逗号,有半角(,)和全角(,)之分的,其实空格也有。0x3000是全角的空格,0x20是半角的空格。你最好把这个语句的后面空白部分,都删除掉,免得有不可见的全角空格。10 加上 _Terror C2664: intswprintf_s(wchar_t *,size_t,const wchar_t *,.) : cannot convert parameter 3from const char 24 to const wchar_t *错误C2664: int swprintf年代(wchar t *,大小t,t * wchar const,)“:不能转换参数3从“const char24”到“const wchar t *_stprintf_s(filename,MAX_PATH, _T(C:Programrwini_%d.ini),nPlugInId);_T(C:Programrwini_%d.ini) 相当于 LPTSTR11无法打开预编译头文件的解决方法编辑程序,按Ctrl+F7,出现下列错误:fatalerrorC1083:无法打开预编译头文件:“Debug/UGFace.pch”:Nosuchfileordirectory解决方法:修改:项目-属性-C/C+-预编译头-不使用预编译头即可。121inifile.obj :error LNK2019: unresolved external symbol private: _thiscallCsaveFileNameA:CsaveFileNameA(class CFileNameA *,classstd:basic_stringchar,struct std:char_traits,classstd:allocator const &)(?0CsaveFileNameAAAEPAVCFileNameAABV?$basic_stringDU?$char_traitsDstdV?$allocatorD2stdZ)referenced in function public: class CsaveFileNameA * _thiscallCFileNameA:AddFileName(class std:basic_stringchar,structstd:char_traits,class std:allocator)(?AddFileNameCFileNameAQAEPAVCsaveFileNameAV?$basic_stringDU?$char_traitsDstdV?$allocatorD2stdZ)错误是CsaveFileNameA没有实现,即没有写CsaveFileNameA构造函数和析构函数131e:gcsrccoreinifile.h(344):error C2143: syntax error : missing ; before *错误原因CIniFileW* PIniFile;应用的类在该类的下面,未定义;classCFileNameWpublic:staticconstwchar_t*constLF;public: CFileNameW(); CFileNameW();classCsaveFileNameW friendclassCFileNameW;#ifdef_WIN32/ Added forversions earlier than VS2008#ifdefined(_MSC_VER) & (_MSC_VER m_sFileName.c_str(), s2-m_sFileName.c_str() m_sFileName.c_str(), s2-m_sFileName.c_str() 0;#endif ;typedefstd:set FileIndexW;#ifdef_WIN32#ifdefined(_MSC_VER) & (_MSC_VER = 1200)& (_MSC_VER 1300)friendclassCsaveFileNameW;#endif#endifpublic: CsaveFileNameW* GetFileName( std:wstringsFileName );/CsaveFileNameW*GetFileName( std:wstring sFileName ) const; FileIndexW:const_iterator _find_file(conststd:wstring& sFileName )const; FileIndexW:iterator _find_file(conststd:wstring& sFileName );voidRemoveAllFileNames( );private: FileIndexW m_filenames;classCIniFileWpublic:staticconstwchar_t*constLF;public: CIniFileW(); CIniFileW();/ Usedto save the data back to the file or your choiceboolSave(conststd:wstring& fileName );修改在前面加上 class CIniFileW即为:classCIniFileW;classCFileNameWpublic:staticconstwchar_t*constLF;public: CFileNameW(); CFileNameW();classCsaveFileNameW friendclassCFileNameW;#ifdef_WIN32/ Added forversions earlier than VS2008#ifdefined(_MSC_VER) & (_MSC_VER m_sFileName.c_str(), s2-m_sFileName.c_str() m_sFileName.c_str(), s2-m_sFileName.c_str() 0;#endif ;typedefstd:set FileIndexW;#ifdef_WIN32#ifdefined(_MSC_VER) & (_MSC_VER = 1200)& (_MSC_VER 1300)friendclassCsaveFileNameW;#endif#endifpublic: CsaveFileNameW* GetFileName( std:wstringsFileName );/CsaveFileNameW*GetFileName( std:wstring sFileName ) const; FileIndexW:const_iterator _find_file(conststd:wstring& sFileName )const; FileIndexW:iterator _find_file(conststd:wstring& sFileName );voidRemoveAllFileNames( );private: FileIndexW m_filenames;classCIniFileWpublic:staticconstwchar_t*constLF;public: CIniFileW(); CIniFileW();/ Usedto save the data back to the file or your choiceboolSave(conststd:wstring& fileName );14error C2248:CFileNameW:CsaveFileNameW:PIniFile : cannot access privatemember declared in class CFileNameW:CsaveFileNameW错误C2248:“CFileNameW:PIniFileCsaveFileNameW”:不能访问私有成员中声明的类的CFileNameW:CsaveFileNameW”改正:把PIniFile改成公有的;public: CIniFileW* PIniFile;15error C2440: initializing : cannot convert from wchar_t * to TCHAR修改前:CString Description;CString Ddvalue =_T(Command description);SsnGetLocaleString(SSN_PLUGIN_ID_ANY,Ddvalue, SSN_AUTO_SELECT_LOCALE,NULL,Ddvalue,Description.GetBuffer(), MAX_PATH,Ddvalue);CString Hotkeys;CString Hdvalue =_T(Hotkeys);SsnGetLocaleString(SSN_PLUGIN_ID_ANY,Hdvalue, SSN_AUTO_SELECT_LOCALE,NULL,Hdvalue,Hotkeys.GetBuffer(), MAX_PATH,Hdvalue);TCHAR rgtsz2MAX_PATH=Description.GetBuffer(),Hdvalue.GetBuffer();修改后: CString Description;CString Ddvalue =_T(Command description);SsnGetLocaleString(SSN_PLUGIN_ID_ANY,Ddvalue, SSN_AUTO_SELECT_LOCALE,NULL,Ddvalue,Description.GetBuffer(), MAX_PATH,Ddvalue);CString Hotkeys;CString Hdvalue =_T(Hotkeys);SsnGetLocaleString(SSN_PLUGIN_ID_ANY,Hdvalue, SSN_AUTO_SELECT_LOCALE,NULL,Hdvalue,Hotkeys.GetBuffer(), MAX_PATH,Hdvalue);TCHAR *rgtsz2=Description.GetBuffer(),Hdvalue.GetBuffer();给二维数组赋值;16 warning C4627: #include : skipped when looking for precompiled header use解决方法:加上头文件#include stdafx.h17CString与char的转换问题,用强制转换报了如下错误,应该如何进行转换呢?CString strName;TCItem.item.pszText= ok ;/显示正常TCItem.item.pszText=(char)strName;/报如下错误error C2440: type cast : cannot convert from class CString to char No user-defined-conversion operator available that can perform this conversion, or the operator cannot be calledError executing cl.exe.解决方法:(char *)&strName18 关于VC 的 error C3872: 0x3000:今天在网上看到了些技术代码(关于按钮动态生成菜单的代码.好象都是一个人写的吧.几乎都没有什么变化),于是边拷贝代码边测试执行程序的结果,想不到碰到了麻烦,简单的两行代码执行时居然出了十多行的error提示:Error 1 error C3872: 0x3000: this character is not allowed in an identifier但是看上去代码明明是对的,没错啊!于是双击提示查看是哪里出的错,结果光标停在了一行注释上,那是一起拷贝进来的一些注释文字。想想也没用,删除,再运行,结果程序顺利执行完毕了。后来发现是一些网页上的非正常格式的空格在做怪,应该是字符码的问题,它与VS中的字符不兼容,所以VS编译程序时无法识别此类字符串,于是报错。注释有的时候就出现莫名其妙的问题.19iostream 的用法,头文件后面不能加.h#includeusing namespace std;20 error LNK2005: int _cdecl PiShowListDialog(struct _SSN_OBJECT_ID_,struct _SSN_OBJECT_ID_) (?PiShowListDialogYAHU_SSN_OBJECT_ID_0Z) already defined in DlgDefaultList.obj错误代表同一个工程里,有两个PiShowListDialog函数!21致命错误C1010:在寻找预编译指示头文件时,文件未预期结束。就是没有找到预编译指示信息的头文件。 问题一般发生在:通过添加文件的方式,添加了一些cpp文件到一个MFC的程序,但该cpp文件并不是MFC,而是标准的C+。 解决方案1: 右键单击项目工程中的cpp文件,在菜单Project-Settings-C/C+-Precompile Header,设置为第一项:Not using precompile headers。 解决方案2:在.cpp文件开头添加包含文件stdafx.h。 #includestdafx.h22 error C2664: “LoadLibraryW”: 不能将参数 1 从“const char *”转换为“LPCWSTR”1 静态调用DLLProject | settingLink选项卡Library modules处添加“XXX.lib”然后#include “XXX.h”把XXX.lib(引入库文件),XXX.DLL(动态库文件)XXX.h(头文件)全部放到工程目录下2 动态调用DLL通过LoadLibraryGetProcAddressFreeLibrary实现。原因 :工程只支持UNICODE字符解决方法:1、工程属性-配置属性常规字符集-使用多字节符字符集2、也就是宽字符,所以下面这行代码,应该编译有错误hinst=LoadLibrary(“InTheHand.Net.Personal.dll”);也就是:cannot convert parameter 1 from char 27 to const unsigned short *楼主将代码改为:hinst=LoadLibrary(L”InTheHand.Net.Personal.dll”);或者hinst=LoadLibrary(_T(“InTheHand.Net.Personal.dll”);试试22warning C6387: argument 1 might be 0: this does not adhere to the specification for the function GlobalLock: Lines: 328, 329, 330, 332, 333, 334, 335就是未对输入是否为空,进行判断!23AfxMessageBox(click);错误 error C2665: AfxMessageBox : none of the 2 overloads could convert all the argument types解决方法:AfxMessageBox(_T(click);解释:如果程序中define _UNICODE,则可用_T or _TEXT将后面的内容转为UNICODE格式字符串,否则和不用_T一样或者就修改项目属性里面的字符编码24 LNK2005: class ATL:CStringTwchar_t,class StrTraitMFC_DLLwchar_t,class ATL:ChTraitsCRT NextSpeakString (?N
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年点心行业研究报告及未来行业发展趋势预测
- 历年物理竞赛试题及答案
- 教师招聘之《幼儿教师招聘》练习题库有答案详解
- 渔业养殖水产品与健康饮食书籍出版创新创业项目商业计划书
- 教师招聘之《小学教师招聘》题库检测模拟题【模拟题】附答案详解
- 教师招聘之《幼儿教师招聘》考试综合练习完整参考答案详解
- 2025年教师招聘之《小学教师招聘》题库高频难、易错点100题模拟试题及参考答案详解(黄金题型)
- 教师招聘之《幼儿教师招聘》强化训练含答案详解(模拟题)
- 押题宝典教师招聘之《幼儿教师招聘》考试题库带答案详解(基础题)
- 教师招聘之《小学教师招聘》高分题库附答案详解【满分必刷】
- 数学-湖南省长郡中学2025-2026学年高二上学期暑假作业检测(开学)试题+答案
- 构建餐饮油烟共治格局的策略及实施路径
- 检测基础知识培训课件
- 前交叉韧带重建手术质量评价规范
- 国企招聘笔试题及答案-投资专员、投资经理B卷
- 2025年四川医疗卫生事业单位《卫生公共基础知识》考试真题及答案
- 民航企业管理概论课件
- 解读学习2025年《住房租赁条例》培训课件
- Q-JJJ 9002-2025 铁路建设项目安全穿透式管理实施指南
- 视网膜静脉周围炎诊断
- 睾丸鞘膜积液护理查房
评论
0/150
提交评论