error C2065:未声明的标识符错误

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/osummertime/article/details/51992906

遇到奇怪的问题

明明导入相关头文件

却还提示,未定义

搜索相关错误

得到结论

要把头文件加载顺序调换

#include "StdAfx.h"

放在最前面可以解决

展开阅读全文

error C2065: “m_pStrategyDlg”: 未声明标识符

10-28

新手请教个问题,网上查了半天也没找到原因。rnTESTStrategy.h里定义一个对话框的(TestItpDialog* m_pStrategyDlg;),但在TESTStrategy.cpp里面Strategy_CreatWindow函数使用该变量时总是提示“error C2065: “m_pStrategyDlg”: 未声明的标识符”。rnTESTSTRATEGY.H代码:rn#pragma oncern#include "strategybase.h"rn#include "list"rn#include rn#include "map"rn#include "TestItpDialog.h"//TestItpDialog 类的头文件rnrnusing std::vector;rnusing std::list;rnusing std::map;rnrnconst int MAX_BAR_SIZE = 1000;rnrnclass TestStrategy :rnpublic CStrategyBasernrnpublic:rnTestStrategy(void);rn~TestStrategy(void);rnrnvirtual int Strategy_OnStart(IiTPInterface* piTP);rnvirtual int Strategy_OnStop(IiTPInterface* piTP);rnvirtual int Strategy_CreatWindow(HWND hWnd,HWND hWndParent);rnvirtual int Strategy_DestroyWindow(HWND hWnd);rnrnprivate:rnrnTestItpDialog* m_pStrategyDlg; // 策略窗口rnrn;rnrnTESTStrategy.cpp里rnint Strategy_CreatWindow(HWND hWnd,HWND hWndParent)rnrn// 创建策略窗口rnAFX_MANAGE_STATE(AfxGetStaticModuleState());rnm_pStrategyDlg = new TestTipDialog;rnif (NULL == m_pStrategyDlg)rnrnASSERT(FALSE);rnreturn -1;rnrnif (!::IsWindow(m_pStrategyDlg->GetSafeHwnd()) && !m_pStrategyDlg->Create(TestItpDialog::IDD))rn rn return -1;rn rnm_pStrategyDlg->ModifyStyleEx(WS_POPUP | WS_BORDER | WS_DLGFRAME,WS_CHILD);rn hWnd = m_pStrategyDlg->GetSafeHwnd();rnreturn 0;rnrnrn 论坛

error C2065: “_ConnectionPtr”: 未声明标识符

01-16

莫名其妙啊,以前从来没遇到这问题,今天终于碰到了,大家看看我哪里出问题了rn1、在stdafx.h 最后包含rn[code=c]rn#import "c:\program files\common files\system\ado\msado15.dll" named_guids rename_namespace("ADOCG") rename("EOF", "adoEOF") rename("BOF","adoBOF")rnusing namespace ADOCGrn[/code]rn2、然后我自定义了一个类函数rn[code=c]rnvoid CIOCPModel::WriteIntoDataBase(CString str1, CString str2)rn//str1、str2是传进来的字符串rnrn CoInitialize(NULL);rn _ConnectionPtr m_pConnection; //连接对象指针rn tryrn rn m_pConnection.CreateInstance("ADODB.Connection"); //创建连接对象实例rn bstr_t strConnect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Modbus_TCP.mdb;Persist Security Info=False";rn m_pConnection->Open(strConnect,"","",adModeUnknown); //打开数据库rn rn catch (_com_error e) //捕捉错误rn rn AfxMessageBox(e.Description()); rn return;//弹出错误rn rn tryrn rn _bstr_t sql = _T("INSERT INTO message (时间,内容) VALUES (str1,str2)");rn m_pConnection->Execute(sql,NULL,adCmdText);rn rn catch (_com_error e)rn rn AfxMessageBox(e.Description()); rn return;//弹出错误rn rnrn m_pConnection->Close();rn CoUninitialize();rnrn[/code]rn3、结果就悲剧了,大家帮我看看是漏了什么还是。。。rn[code=text]rn错误信息rn错误 7 error C2065: “_ConnectionPtr”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 814 PiggyIOCPServerrn错误 8 error C2146: 语法错误 : 缺少“;”(在标识符“m_pConnection”的前面) c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 814 PiggyIOCPServerrn错误 9 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 814 PiggyIOCPServerrn错误 10 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 817 PiggyIOCPServerrn错误 11 error C2228: “.CreateInstance”的左边必须有类/结构/联合 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 817 PiggyIOCPServerrn错误 12 error C2065: “bstr_t”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 818 PiggyIOCPServerrn错误 13 error C2146: 语法错误 : 缺少“;”(在标识符“strConnect”的前面) c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 818 PiggyIOCPServerrn错误 14 error C2065: “strConnect”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 818 PiggyIOCPServerrn错误 15 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 16 error C2227: “->Open”的左边必须指向类/结构/联合/泛型类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 17 error C2065: “strConnect”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 18 error C2065: “adModeUnknown”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 819 PiggyIOCPServerrn错误 19 error C2061: 语法错误 : 标识符“_com_error” c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 821 PiggyIOCPServerrn错误 20 error C2310: catch 处理程序必须指定一种类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 821 PiggyIOCPServerrn错误 21 error C2065: “e”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 823 PiggyIOCPServerrn错误 22 error C2228: “.Description”的左边必须有类/结构/联合 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 823 PiggyIOCPServerrn错误 23 error C2317: 在行“816”上开始的“try”块没有 catch 处理程序 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 826 PiggyIOCPServerrn错误 24 error C2065: “_bstr_t”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 828 PiggyIOCPServerrn错误 25 error C2146: 语法错误 : 缺少“;”(在标识符“sql”的前面) c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 828 PiggyIOCPServerrn错误 26 error C2065: “sql”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 828 PiggyIOCPServerrn错误 27 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 28 error C2227: “->Execute”的左边必须指向类/结构/联合/泛型类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 29 error C2065: “sql”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 30 error C2065: “adCmdText”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 829 PiggyIOCPServerrn错误 31 error C2061: 语法错误 : 标识符“_com_error” c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 831 PiggyIOCPServerrn错误 32 error C2310: catch 处理程序必须指定一种类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 831 PiggyIOCPServerrn错误 33 error C2065: “e”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 833 PiggyIOCPServerrn错误 34 error C2228: “.Description”的左边必须有类/结构/联合 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 833 PiggyIOCPServerrn错误 35 error C2317: 在行“827”上开始的“try”块没有 catch 处理程序 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 837 PiggyIOCPServerrn错误 36 error C2065: “m_pConnection”: 未声明的标识符 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 837 PiggyIOCPServerrn错误 37 error C2227: “->Close”的左边必须指向类/结构/联合/泛型类型 c:\users\asus\desktop\myservice\piggyiocpserver\iocpmodel.cpp 837 PiggyIOCPServerrnrn[/code] 论坛

没有更多推荐了,返回首页